From f4fec1f047e25042ba36a7f069cec0cfd5eb291a Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 6 Aug 2024 14:35:29 -0400 Subject: [PATCH 1/3] Denoise MNI152NLin6Asym:res-2 data. --- src/fmripost_aroma/workflows/base.py | 30 ++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/fmripost_aroma/workflows/base.py b/src/fmripost_aroma/workflows/base.py index 3b63f23..4b1e044 100644 --- a/src/fmripost_aroma/workflows/base.py +++ b/src/fmripost_aroma/workflows/base.py @@ -399,6 +399,24 @@ def init_single_run_wf(bold_file): ica_aroma_wf.inputs.inputnode.confounds = functional_cache['confounds'] ica_aroma_wf.inputs.inputnode.skip_vols = skip_vols + if config.workflow.denoise_method: + # Now denoise the output-space BOLD data using ICA-AROMA + denoise_wf = init_denoise_wf(bold_file=bold_file) + denoise_wf.inputs.inputnode.skip_vols = skip_vols + denoise_wf.inputs.inputnode.space = 'MNI152NLin6Asym' + denoise_wf.inputs.inputnode.resolution = '2' + + workflow.connect([ + (mni6_buffer, denoise_wf, [ + ('bold_mni152nlin6asym', 'inputnode.bold_file'), + ('bold_mask_mni152nlin6asym', 'inputnode.bold_mask'), + ]), + (ica_aroma_wf, denoise_wf, [ + ('outputnode.mixing', 'inputnode.mixing'), + ('outputnode.aroma_features', 'inputnode.classifications'), + ]), + ]) # fmt:skip + if config.workflow.denoise_method and spaces.get_spaces(): templates = spaces.get_spaces() template_iterator_wf = init_template_iterator_wf( @@ -411,15 +429,15 @@ def init_single_run_wf(bold_file): template_iterator_wf.inputs.inputnode.template = templates # Now denoise the output-space BOLD data using ICA-AROMA - denoise_wf = init_denoise_wf(bold_file=bold_file) - denoise_wf.inputs.inputnode.skip_vols = skip_vols + denoise_std_wf = init_denoise_wf(bold_file=bold_file) + denoise_std_wf.inputs.inputnode.skip_vols = skip_vols workflow.connect([ - (ica_aroma_wf, denoise_wf, [ + (ica_aroma_wf, denoise_std_wf, [ ('outputnode.mixing', 'inputnode.mixing'), ('outputnode.aroma_features', 'inputnode.classifications'), ]), - (template_iterator_wf, denoise_wf, [ + (template_iterator_wf, denoise_std_wf, [ ('outputnode.space', 'inputnode.space'), ('outputnode.cohort', 'inputnode.cohort'), ('outputnode.resolution', 'inputnode.resolution'), @@ -439,7 +457,7 @@ def init_single_run_wf(bold_file): std_buffer.inputs.bold_mask = functional_cache['bold_mask_outputspaces'] workflow.connect([ (template_iterator_wf, std_buffer, [('outputnode.space', 'key')]), - (std_buffer, denoise_wf, [ + (std_buffer, denoise_std_wf, [ ('bold', 'inputnode.bold_file'), ('bold_mask', 'inputnode.bold_mask'), ]), @@ -470,7 +488,7 @@ def init_single_run_wf(bold_file): ('outputnode.cohort', 'inputnode.cohort'), ]), (all_xfms, resample_std_wf, [('out', 'inputnode.transforms')]), - (resample_std_wf, denoise_wf, [ + (resample_std_wf, denoise_std_wf, [ ('outputnode.bold_std', 'inputnode.bold'), ('outputnode.bold_mask_std', 'inputnode.bold_mask'), ]), From b2d88c21c1d3210a35d43e64cce28e6bed75c276 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 6 Aug 2024 14:38:35 -0400 Subject: [PATCH 2/3] Update base.py --- src/fmripost_aroma/workflows/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fmripost_aroma/workflows/base.py b/src/fmripost_aroma/workflows/base.py index 4b1e044..b25749a 100644 --- a/src/fmripost_aroma/workflows/base.py +++ b/src/fmripost_aroma/workflows/base.py @@ -417,7 +417,8 @@ def init_single_run_wf(bold_file): ]), ]) # fmt:skip - if config.workflow.denoise_method and spaces.get_spaces(): + # Skip this for now + if config.workflow.denoise_method and spaces.get_spaces() and False: templates = spaces.get_spaces() template_iterator_wf = init_template_iterator_wf( spaces=spaces, From 0a2674a0195c02d7839a8bd5cfaf7dc0bd7d9c81 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 6 Aug 2024 14:59:49 -0400 Subject: [PATCH 3/3] Update aroma.py --- src/fmripost_aroma/workflows/aroma.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/fmripost_aroma/workflows/aroma.py b/src/fmripost_aroma/workflows/aroma.py index b08fd19..f34ba96 100644 --- a/src/fmripost_aroma/workflows/aroma.py +++ b/src/fmripost_aroma/workflows/aroma.py @@ -471,7 +471,7 @@ def init_denoise_wf(bold_file): (inputnode, ds_denoised, [ ('space', 'space'), ('cohort', 'cohort'), - ('resolution', 'res'), + ('resolution', 'resolution'), ]), (add_non_steady_state, ds_denoised, [('bold_add', 'in_file')]), ]) # fmt:skip @@ -497,7 +497,7 @@ def _remove_volumes(bold_file, skip_vols): if skip_vols == 0: return bold_file - out = fname_presuffix(bold_file, suffix='_cut', newpath=os.getcwd()) + out = fname_presuffix(bold_file, prefix='cut_', newpath=os.getcwd()) bold_img = nb.load(bold_file) bold_img.__class__( bold_img.dataobj[..., skip_vols:], bold_img.affine, bold_img.header @@ -507,6 +507,8 @@ def _remove_volumes(bold_file, skip_vols): def _add_volumes(bold_file, bold_cut_file, skip_vols): """Prepend skip_vols from bold_file onto bold_cut_file.""" + import os + import nibabel as nb import numpy as np from nipype.utils.filemanip import fname_presuffix @@ -519,7 +521,7 @@ def _add_volumes(bold_file, bold_cut_file, skip_vols): bold_data = np.concatenate((bold_img.dataobj[..., :skip_vols], bold_cut_img.dataobj), axis=3) - out = fname_presuffix(bold_cut_file, suffix='_addnonsteady') + out = fname_presuffix(bold_cut_file, prefix='addnonsteady_', newpath=os.getcwd()) bold_img.__class__(bold_data, bold_img.affine, bold_img.header).to_filename(out) return out