Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Update subworkflow preproc_t1 #35

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions subworkflows/nf-neuro/preproc_t1/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,37 @@ workflow PREPROC_T1 {
ch_versions = Channel.empty()

// ** Denoising ** //
ch_nlmeans = ch_image.join(ch_mask_nlmeans)
ch_nlmeans = ch_image
.join(ch_mask_nlmeans, remainder: true)
.map{ it[0..1] + [it[2] ?: []] }

DENOISING_NLMEANS ( ch_nlmeans )
ch_versions = ch_versions.mix(DENOISING_NLMEANS.out.versions.first())

// ** N4 correction ** //
ch_N4 = DENOISING_NLMEANS.out.image.join(ch_ref_n4)
ch_N4 = DENOISING_NLMEANS.out.image
.join(ch_ref_n4, remainder: true)
.map{ it[0..1] + [it[2] ?: []] }
.join(ch_mask_nlmeans, remainder: true)
.map{ it[0..2] + [it[3] ?: []] }

PREPROC_N4 ( ch_N4 )
ch_versions = ch_versions.mix(PREPROC_N4.out.versions.first())

// ** Resampling ** //
ch_resampling = PREPROC_N4.out.image.join(ch_ref_resample)
ch_resampling = PREPROC_N4.out.image
.join(ch_ref_resample, remainder: true)
.map{ it[0..1] + [it[2] ?: []] }

IMAGE_RESAMPLE ( ch_resampling )
ch_versions = ch_versions.mix(IMAGE_RESAMPLE.out.versions.first())

// ** Brain extraction ** //
if ( params.run_synthbet) {
ch_bet = IMAGE_RESAMPLE.out.image.join(ch_weights)
ch_bet = IMAGE_RESAMPLE.out.image
.join(ch_weights, remainder: true)
.map{ it[0..1] + [it[2] ?: []] }

BETCROP_SYNTHBET ( ch_bet )
ch_versions = ch_versions.mix(BETCROP_SYNTHBET.out.versions.first())

Expand All @@ -51,9 +65,10 @@ workflow PREPROC_T1 {
}

else {
ch_template = ch_template.ifEmpty(Channel.error('Template is required for ANTS registration'))
ch_probability_map = ch_probability_map.ifEmpty(Channel.error('Probability map is required for ANTS registration'))
ch_bet = IMAGE_RESAMPLE.out.image.join(ch_template).join(ch_probability_map)
ch_bet = IMAGE_RESAMPLE.out.image
.join(ch_template)
.join(ch_probability_map)

BETCROP_ANTSBET ( ch_bet )
ch_versions = ch_versions.mix(BETCROP_ANTSBET.out.versions.first())

Expand All @@ -62,13 +77,16 @@ workflow PREPROC_T1 {
mask_bet = BETCROP_ANTSBET.out.mask
}

// ** crop image ** //
ch_crop = image_bet.map{it + [[]]}
// ** Crop image ** //
ch_crop = image_bet
.map{ it + [[]] }

BETCROP_CROPVOLUME_T1 ( ch_crop )
ch_versions = ch_versions.mix(BETCROP_CROPVOLUME_T1.out.versions.first())

// ** crop mask ** //
ch_crop_mask = mask_bet.join(BETCROP_CROPVOLUME_T1.out.bounding_box)
// ** Crop mask ** //
ch_crop_mask = mask_bet
.join(BETCROP_CROPVOLUME_T1.out.bounding_box)

BETCROP_CROPVOLUME_MASK ( ch_crop_mask )
ch_versions = ch_versions.mix(BETCROP_CROPVOLUME_MASK.out.versions.first())
Expand Down