Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dist/
.idea/
.env
.envrc
.devcontainer/devcontainer.json
Comment thread
bendhouseart marked this conversation as resolved.
Outdated

# Additional
.ipynb_checkpoints/
Expand Down
7 changes: 6 additions & 1 deletion petprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def main():
# CRITICAL Call build_workflow(config_file, retval) in a subprocess.
# Because Python on Linux does not ever free virtual memory (VM), running the
# workflow construction jailed within a process preempts excessive VM buildup.
if 'pdb' not in config.execution.debug:
# Skip multiprocessing if debugging (pdb) or if running under a debugger

is_debugging = (
'pdb' in config.execution.debug or hasattr(sys, 'gettrace') and sys.gettrace() is not None
)
if not is_debugging:
Comment thread
bendhouseart marked this conversation as resolved.
Outdated
with Manager() as mgr:
retval = mgr.dict()
p = Process(target=build_workflow, args=(str(config_file), retval))
Expand Down
20 changes: 13 additions & 7 deletions petprep/data/nipreps.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,21 @@
"name": "cohort",
"pattern": "[_/\\\\]+cohort-0*(\\d+)",
"dtype": "int"
},
{
"name": "seg",
"pattern": "[_/\\\\]+seg-([a-zA-Z0-9+]+)"
}
],
"default_path_patterns": [
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2starmap|FLAIR|FLASH|PDmap|PD|PDT2|dseg|inplaneT[12]|angio|T2starw|MTw|TSE>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_seg-{seg}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2starmap|FLAIR|FLASH|PDmap|PD|PDT2|dseg|inplaneT[12]|angio|T2starw|MTw|TSE>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_hemi-{hemi<L|R>}]_from-{from}_to-{to}_mode-{mode<image|points>|image}_{suffix<xfm>|xfm}{extension<.txt|.h5>}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}]_hemi-{hemi<L|R>}[_space-{space}][_cohort-{cohort}][_den-{density}][_desc-{desc}]_{suffix<white|smoothwm|pial|midthickness|inflated|vinflated|sphere|flat|sulc|curv|thickness>}{extension<.surf.gii|.shape.gii>}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_den-{density}][_desc-{desc}]_{suffix<sulc|curv|thickness>}{extension<.dscalar.nii|.json>}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]_desc-{desc}_{suffix<mask>|mask}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_label-{label}]_desc-{desc}_{suffix<mask>|mask}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]_label-{label}[_desc-{desc}]_{suffix<probseg>|probseg}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_seg-{seg}][_desc-{desc}]_{suffix<dseg>}{extension<.tsv|.json>|.tsv}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_seg-{seg}][_label-{label}][_desc-{desc}]_{suffix<morph>}{extension<.tsv|.json>|.tsv}",
"sub-{subject}[/ses-{session}]/{datatype<func>|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_part-{part}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_desc-{desc}]_{suffix<bold|cbv|sbref|boldref|boldmap|dseg>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<func>|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_desc-{desc}]_{suffix<phase>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<func>|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_hemi-{hemi<L|R>}]_from-{from}_to-{to}_mode-{mode<image|points>|image}[_desc-{desc}]_{suffix<xfm>|xfm}{extension<.txt|.h5>}",
Expand All @@ -187,11 +193,11 @@
"sub-{subject}[/ses-{session}]/{datatype<pet>|pet}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_trc-{tracer}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_den-{density}][_desc-{desc}]_{suffix<sulc|curv|thickness>}{extension<.dscalar.nii|.json>}",
"sub-{subject}[/ses-{session}]/{datatype<pet>|pet}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_trc-{tracer}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]_desc-{desc}_{suffix<mask>|mask}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<pet>|pet}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_trc-{tracer}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]_label-{label}[_desc-{desc}]_{suffix<probseg>|probseg}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<pet>|pet}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_trc-{tracer}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_part-{part}][_space-{space}][_atlas-{atlas}][_cohort-{cohort}][_desc-{desc}]_{suffix<timeseries|regressors>|timeseries}{extension<.json|.tsv>|.tsv}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2star|FLAIR|FLASH|PDmap|PD|PDT2|inplaneT[12]|angio|dseg|mask|T2starw|MTw|TSE|pet>}{extension<.html|.svg>|.svg}",
"sub-{subject}[/ses-{session}]/{datatype<pet>|pet}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_trc-{tracer}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_part-{part}][_space-{space}][_atlas-{atlas}][_cohort-{cohort}][_seg-{seg}][_label-{label}][_desc-{desc}]_{suffix<timeseries|regressors|tacs>|timeseries}{extension<.json|.tsv>|.tsv}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_label-{label}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2star|FLAIR|FLASH|PDmap|PD|PDT2|inplaneT[12]|angio|dseg|mask|T2starw|MTw|TSE|pet>}{extension<.html|.svg>|.svg}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_fmapid-{fmapid}][_desc-{desc}]_{suffix<fieldmap>}{extension<.html|.svg>|.svg}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_part-{part}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<dwi|epi|epiref|pet>}{extension<.html|.svg>|.svg}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_part-{part}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<bold|boldmap|pet>}{extension<.html|.svg>|.svg}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_trc-{tracer}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<pet>}{extension<.html|.svg|.png>|.html}"
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_part-{part}][_space-{space}][_cohort-{cohort}][_label-{label}][_desc-{desc}]_{suffix<dwi|epi|epiref|pet>}{extension<.html|.svg>|.svg}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_part-{part}][_space-{space}][_cohort-{cohort}][_label-{label}][_desc-{desc}]_{suffix<bold|boldmap|pet>}{extension<.html|.svg>|.svg}",
"sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_trc-{tracer}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_label-{label}][_desc-{desc}]_{suffix<pet>}{extension<.html|.svg|.png>|.html}"
]
}
8 changes: 8 additions & 0 deletions petprep/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
from json import loads

from niworkflows.interfaces.bids import DerivativesDataSink as _DDSink

from petprep.utils.bids import load_data

from .cifti import GeneratePetCifti
from .motion import MotionPlot
from .reports import AtlasROIsReport
Expand All @@ -10,6 +14,10 @@

class DerivativesDataSink(_DDSink):
out_path_base = ''
_petprep_spec = loads(load_data.readable('nipreps.json').read_text())
_config_entities = frozenset({e['name'] for e in _petprep_spec['entities']})
_config_entities_dict = _petprep_spec['entities']
_file_patterns = tuple(_petprep_spec['default_path_patterns'])


__all__ = (
Expand Down
4 changes: 0 additions & 4 deletions petprep/workflows/pet/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def init_func_fit_reports_wf(
desc='ref',
label=ref_name,
datatype='figures',
allowed_entities=('label',),
),
name='ds_report_refmask',
run_without_submitting=True,
Expand Down Expand Up @@ -362,7 +361,6 @@ def init_func_fit_reports_wf(
label=ref_name,
suffix='pet',
datatype='figures',
allowed_entities=('label',),
),
name='ds_pet_t1_refmask_report',
)
Expand Down Expand Up @@ -573,7 +571,6 @@ def init_ds_refmask_wf(
suffix='mask',
desc='ref',
label=ref_name,
allowed_entities=('label',),
compress=True,
),
name='ds_refmask',
Expand Down Expand Up @@ -1060,7 +1057,6 @@ def init_refmask_report_wf(
desc='ref',
label=ref_name,
datatype='figures',
allowed_entities=('label',),
suffix='pet',
),
name='ds_report_refmask',
Expand Down
1 change: 0 additions & 1 deletion petprep/workflows/pet/reference_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def init_pet_refmask_wf(
base_directory=config.execution.petprep_dir,
label=ref_mask_name,
desc='ref',
allowed_entities=('label',),
suffix='morph',
extension='.tsv',
datatype='anat',
Expand Down
3 changes: 0 additions & 3 deletions petprep/workflows/pet/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def _build_nodes(
DerivativesDataSink(
base_directory=config.execution.petprep_dir,
seg=seg,
allowed_entities=('seg',),
suffix='dseg',
extension='.nii.gz',
compress=True,
Expand Down Expand Up @@ -233,7 +232,6 @@ def _build_nodes(
DerivativesDataSink(
base_directory=config.execution.petprep_dir,
seg=seg,
allowed_entities=('seg',),
suffix='dseg',
extension='.tsv',
datatype='anat',
Expand All @@ -247,7 +245,6 @@ def _build_nodes(
DerivativesDataSink(
base_directory=config.execution.petprep_dir,
seg=seg,
allowed_entities=('seg',),
suffix='morph',
extension='.tsv',
datatype='anat',
Expand Down
5 changes: 3 additions & 2 deletions petprep/workflows/pet/tests/test_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ def test_refmask_report_connections(bids_root: Path, tmp_path: Path, pvc_method)
ds_tacs = wf.get_node('ds_ref_tacs')
assert ds_tacs.inputs.label == 'cerebellum'
assert 'label' in ds_tacs.interface._allowed_entities
assert 'seg' not in ds_tacs.interface._allowed_entities
assert not hasattr(ds_tacs.inputs, 'seg')
assert 'seg' in ds_tacs.interface._config_entities
assert hasattr(ds_tacs.inputs, 'seg')
assert ds_tacs.inputs.seg is Undefined
assert ds_tacs.inputs.desc == 'preproc'
edge_tacs = wf._graph.get_edge_data(wf.get_node('pet_ref_tacs_wf'), ds_tacs)
assert ('outputnode.timeseries', 'in_file') in edge_tacs['connect']
Expand Down
Loading