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

Denoise MNI152NLin6Asym:res-2 #40

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/fmripost_aroma/workflows/aroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
(inputnode, ds_denoised, [
('space', 'space'),
('cohort', 'cohort'),
('resolution', 'res'),
('resolution', 'resolution'),
]),
(add_non_steady_state, ds_denoised, [('bold_add', 'in_file')]),
]) # fmt:skip
Expand All @@ -497,7 +497,7 @@
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())

Check warning on line 500 in src/fmripost_aroma/workflows/aroma.py

View check run for this annotation

Codecov / codecov/patch

src/fmripost_aroma/workflows/aroma.py#L500

Added line #L500 was not covered by tests
bold_img = nb.load(bold_file)
bold_img.__class__(
bold_img.dataobj[..., skip_vols:], bold_img.affine, bold_img.header
Expand All @@ -507,6 +507,8 @@

def _add_volumes(bold_file, bold_cut_file, skip_vols):
"""Prepend skip_vols from bold_file onto bold_cut_file."""
import os

Check warning on line 510 in src/fmripost_aroma/workflows/aroma.py

View check run for this annotation

Codecov / codecov/patch

src/fmripost_aroma/workflows/aroma.py#L510

Added line #L510 was not covered by tests

import nibabel as nb
import numpy as np
from nipype.utils.filemanip import fname_presuffix
Expand All @@ -519,7 +521,7 @@

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())

Check warning on line 524 in src/fmripost_aroma/workflows/aroma.py

View check run for this annotation

Codecov / codecov/patch

src/fmripost_aroma/workflows/aroma.py#L524

Added line #L524 was not covered by tests
bold_img.__class__(bold_data, bold_img.affine, bold_img.header).to_filename(out)
return out

Expand Down
33 changes: 26 additions & 7 deletions src/fmripost_aroma/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,26 @@
ica_aroma_wf.inputs.inputnode.confounds = functional_cache['confounds']
ica_aroma_wf.inputs.inputnode.skip_vols = skip_vols

if config.workflow.denoise_method and spaces.get_spaces():
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'

Check warning on line 407 in src/fmripost_aroma/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

src/fmripost_aroma/workflows/base.py#L404-L407

Added lines #L404 - L407 were not covered by tests

workflow.connect([

Check warning on line 409 in src/fmripost_aroma/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

src/fmripost_aroma/workflows/base.py#L409

Added line #L409 was not covered by tests
(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

# Skip this for now
if config.workflow.denoise_method and spaces.get_spaces() and False:

Check warning on line 421 in src/fmripost_aroma/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

src/fmripost_aroma/workflows/base.py#L421

Added line #L421 was not covered by tests
templates = spaces.get_spaces()
template_iterator_wf = init_template_iterator_wf(
spaces=spaces,
Expand All @@ -411,15 +430,15 @@
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'),
Expand All @@ -439,7 +458,7 @@
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'),
]),
Expand Down Expand Up @@ -470,7 +489,7 @@
('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'),
]),
Expand Down