mriqc icon indicating copy to clipboard operation
mriqc copied to clipboard

WIP: PETQC implementation

Open celprov opened this issue 7 months ago • 5 comments

Draft of the PETQC workflow implementation. I have modified MRIQC to add PET as an accepted modality type. The workflow estimates motion correction parameter using 3dVolReg. I added a node that determines the reference volume as the volume with the highest intensity sum and pass it on to the basefile argument of the VolReg interface. Then, we generate a visual report that plots the framewise displacement, rotation and translation timeseries. It also computes the mean FD, num_fd and perc_fd IQMs.

I did not manage to make it work until the end on the example pet data included in this repo

cc @mnoergaard

celprov avatar May 02 '25 20:05 celprov

Many thanks, @celprov ! I think we need an update in niworkflows on this, particularly adding some pet information to the nipreps.json file. Will open a separate issue and PR to address this. Unless, @mgxd is faster than me ;-)

something like this ' "sub-{subject}/{datatype}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_rec-{reconstruction}][_run-{run}][desc-{desc}]{suffix}{extension<.png|.svg|.html>|.png}"

mnoergaard avatar May 02 '25 20:05 mnoergaard

Still testing this, and narrowing some issues down to pybids and niworkflows. This is after updating the nipreps.json file in niworkflows, so default_path_patterns include pet.

  • BIDS dataset path: /Users/martinnorgaard/Documents/GitHub/mriqc/mriqc/data/pet.
  • Output folder: /Users/martinnorgaard/Documents/GitHub/mriqc/mriqc/data/pet/derivatives/mriqc.
  • Analysis levels: ['participant'].

2025-05-05 10:21:12 | IMPORTANT | mriqc | Extracting metadata and entities for 1 input runs of modality 'pet'... 2025-05-05 10:21:12 | IMPORTANT | mriqc | File size ('pet'): 0.05|0.05 GB [maximum|average]. 2025-05-05 10:21:16 | IMPORTANT | mriqc | Building MRIQC's workflows... 2025-05-05 10:21:19 | IMPORTANT | mriqc | Workflow building finished (exit code 0). DEBUG: entities before Report: {'session': 'baseline', 'subject': '01', 'suffix': 'pet'} DEBUG: report_type: pet Traceback (most recent call last): File "/Users/martinnorgaard/anaconda3/envs/mriqc/bin/mriqc", line 8, in sys.exit(main()) File "/Users/martinnorgaard/Dropbox/Mac/Documents/GitHub/mriqc/mriqc/cli/run.py", line 197, in main generate_reports() File "/Users/martinnorgaard/Dropbox/Mac/Documents/GitHub/mriqc/mriqc/reports/individual.py", line 39, in generate_reports output_files = [_single_report(ff) for mod in config.workflow.inputs.values() for ff in mod] File "/Users/martinnorgaard/Dropbox/Mac/Documents/GitHub/mriqc/mriqc/reports/individual.py", line 39, in output_files = [_single_report(ff) for mod in config.workflow.inputs.values() for ff in mod] File "/Users/martinnorgaard/Dropbox/Mac/Documents/GitHub/mriqc/mriqc/reports/individual.py", line 90, in _single_report robj = Report( File "/Users/martinnorgaard/anaconda3/envs/mriqc/lib/python3.10/site-packages/nireports/assembler/report.py", line 268, in init out_filename = build_path(bids_filters, OUTPUT_NAME_PATTERN) File "/Users/martinnorgaard/anaconda3/envs/mriqc/lib/python3.10/site-packages/bids/layout/writing.py", line 188, in build_path fields = {pat[1] for pat in Formatter().parse(new_path) File "/Users/martinnorgaard/anaconda3/envs/mriqc/lib/python3.10/site-packages/bids/layout/writing.py", line 188, in fields = {pat[1] for pat in Formatter().parse(new_path) ValueError: Single '}' encountered in format string

@effigies @mgxd do you mind taking a quick look to move this forward? Many thanks

mnoergaard avatar May 05 '25 08:05 mnoergaard

Updated nipreps.json with default_path_patterns

"default_path_patterns": [ "sub-{subject}[/ses-{session}]/{datatype|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}/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}{extension<.txt|.h5>}", "sub-{subject}[/ses-{session}]/{datatype|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}/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}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]desc-{desc}{suffix|mask}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|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}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|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}/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}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|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}{extension<.txt|.h5>}", "sub-{subject}[/ses-{session}]/{datatype|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|mask}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|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}][desc-{desc}]{suffix<AROMAnoiseICs>|AROMAnoiseICs}{extension<.csv|.tsv>|.csv}", "sub-{subject}[/ses-{session}]/{datatype|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}][desc-{desc}]{suffix<timeseries|regressors>|timeseries}{extension<.json|.tsv>|.tsv}", "sub-{subject}[/ses-{session}]/{datatype|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}][desc-{desc}]{suffix<components|mixing>|components}{extension<.json|.tsv|.nii|.nii.gz>|.tsv}", "sub-{subject}[/ses-{session}]/{datatype|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}][desc-{desc}]{suffix|decomposition}{extension<.json>|.json}", "sub-{subject}[/ses-{session}]/{datatype|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_echo-{echo}][_hemi-{hemi<L|R>}][_space-{space}][_cohort-{cohort}][_den-{density}][desc-{desc}]{suffix<bold|boldmap>}{extension<.dtseries.nii|.dtseries.json|.func.gii|.func.json>}", "sub-{subject}[/ses-{session}]/{datatype}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][desc-{desc}]{suffix<T2starmap>}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|dwi}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][desc-{desc}]{suffix<dwi|dwiref|epiref|lowb|dseg>}{extension<.json|.nii.gz|.nii>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|dwi}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]desc-{desc}{suffix}{extension<.json|.nii.gz|.nii>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|dwi}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][desc-{desc}]{suffix}{extension<.tsv|.bval|.bvec|.b>|.tsv}", "sub-{subject}[/ses-{session}]/{datatype|dwi}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_rec-{reconstruction}][_dir-{direction}][_run-{run}]_from-{from}_to-{to}_mode-{mode<image|points>|image}[desc-{desc}]{suffix|xfm}{extension<.txt|.h5>}", "sub-{subject}[/ses-{session}]/{datatype|perf}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_rec-{reconstruction}][_dir-{direction}][run-{run}]{suffix}{extension<.tsv|.json>|.tsv}", "sub-{subject}[/ses-{session}]/{datatype|perf}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}]_from-{from}_to-{to}mode-{mode<image|points>|image}{suffix|xfm}{extension<.txt|.h5>}", "sub-{subject}[/ses-{session}]/{datatype|perf}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_space-{space}][_atlas-{atlas}][_cohort-{cohort}][desc-{desc}]{suffix}{extension<.json|.tsv>|.tsv}", "sub-{subject}[/ses-{session}]/{datatype|perf}/sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_dir-{direction}][_run-{run}][_space-{space}][_atlas-{atlas}][_cohort-{cohort}][desc-{desc}]{suffix<asl|aslref|att|cbf|coverage|mask>}{extension<.nii|.nii.gz|.json|.tsv>|.tsv}", "sub-{subject}[/ses-{session}]/{datatype|fmap}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_dir-{direction}][_run-{run}][_part-{part}][_space-{space}][_cohort-{cohort}][_res-{resolution}][_fmapid-{fmapid}][desc-{desc}]{suffix}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|pet}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}][desc-{desc}]{suffix}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|pet}/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}{extension<.txt|.h5>}", "sub-{subject}[/ses-{session}]/{datatype|pet}/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|pet}/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|pet}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]desc-{desc}{suffix|mask}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}[/ses-{session}]/{datatype|pet}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_res-{resolution}]_label-{label}[desc-{desc}]{suffix|probseg}{extension<.nii|.nii.gz|.json>|.nii.gz}", "sub-{subject}/{datatype}/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>}{extension<.html|.svg>|.svg}", "sub-{subject}/{datatype}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_fmapid-{fmapid}][desc-{desc}]{suffix}{extension<.html|.svg>|.svg}", "sub-{subject}/{datatype}/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>}{extension<.html|.svg>|.svg}", "sub-{subject}/{datatype}/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>}{extension<.html|.svg>|.svg}", "sub-{subject}/{datatype}/sub-{subject}[_ses-{session}][desc-{desc}]{suffix}{extension<.png|.svg|.html>|.png}" ]

mnoergaard avatar May 05 '25 08:05 mnoergaard

Adding "sub-{subject}/{datatype}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][desc-{desc}]{suffix}{extension<.png|.svg|.html>|.png}" to the niworkflows nipreps.json file seemed to work out.

Now getting File "/Users/martinnorgaard/Dropbox/Mac/Documents/GitHub/mriqc/mriqc/reports/individual.py", line 90, in _single_report robj = Report( File "/Users/martinnorgaard/anaconda3/envs/mriqc/lib/python3.10/site-packages/nireports/assembler/report.py", line 268, in init out_filename = build_path(bids_filters, OUTPUT_NAME_PATTERN)

This can be fixed by adding "sub-{subject}[_ses-{session}][_acq-{acquisition}][_rec-{reconstruction}]"
"[_run-{run}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<pet>}{extension<.html|.svg|.png>|.html}"

to the OUTPUT_NAME_PATTERN in the nireports/assembler/report.py.

mnoergaard avatar May 09 '25 12:05 mnoergaard

(mriqc) $ mriqc /Users/martinnorgaard/Documents/GitHub/mriqc/mriqc/data/pet/ /Users/martinnorgaard/Documents/GitHub/mriqc/mriqc/data/pet/derivatives/mriqc participant --no-sub

Running MRIQC version 25.1.0.dev49+g1b92a165.d20250509

NOTICE Copyright © The NiPreps Developers.

This product includes software developed by the NiPreps Community (https://nipreps.org/).

Portions of this software were developed at the Department of Psychology at Stanford University, Stanford, CA, US.

This software contains code ultimately derived from the PCP Quality Assessment Protocol (QAP; http://preprocessed-connectomes-project.org/quality-assessment-protocol) by C. Craddock, S. Giavasis, D. Clark, Z. Shezhad, and J. Pellman.

This software is also distributed as a Docker container image. The bootstrapping file for the image ("Dockerfile") is licensed under the MIT License.


  • BIDS dataset path: /Users/martinnorgaard/Documents/GitHub/mriqc/mriqc/data/pet.
  • Output folder: /Users/martinnorgaard/Documents/GitHub/mriqc/mriqc/data/pet/derivatives/mriqc.
  • Analysis levels: ['participant'].

2025-05-09 14:24:38 | IMPORTANT | mriqc | Extracting metadata and entities for 1 input runs of modality 'pet'... 2025-05-09 14:24:38 | IMPORTANT | mriqc | File size ('pet'): 0.05|0.05 GB [maximum|average]. 2025-05-09 14:24:42 | IMPORTANT | mriqc | Building MRIQC's workflows... 2025-05-09 14:24:46 | IMPORTANT | mriqc | Workflow building finished (exit code 0). DEBUG: entities before Report: {'session': 'baseline', 'subject': '01', 'suffix': 'pet'} DEBUG: report_type: pet 2025-05-09 14:26:50 | IMPORTANT | mriqc | Participant level finished successfully averaging 00h 02min 12s per subject.

MRIQC completed (elapsed time 00h 02min 12s).

@celprov

but it needs those prior updates to niworkflows (nipreps.json) and nireports (assembler/report.py) in order to work

mnoergaard avatar May 09 '25 12:05 mnoergaard