No (aparc+)aesg output from fmriprep

Summary of what happened:

Preface: I am new to fMRIPrep.

End goal: Extract timeseries from various ROIs.

Overview: I have run fMRIPrep and there are no errors mentioned in the .html files for each subject. Based on some reading by others on this site and additional information around the internet, it seems like I should be using the (aparc+)aseg files generated by fMRIPrep to created a mask for my data. However, there are no such files in my derivatives directory.

I do have /bids/derivatives/desc-aparcaseg_dseg.tsv and bids/derivatives/desc-aseg_dseg.tsv but no .nii.gz subject specific files.

Command used (and if a helper script was used, a link to the helper script or the command generated):

I am using a custom script, which can be found here on Github.

The fMRIPrep command used in this script:

# get subjects
subs=(${bids_dir}/sub-SL*)

for sub in "${subs[@]}"; do
    singularity run --cleanenv -B /data/jdecke5:/data/jdecke5 $HOME/images/fmriprep.simg \
        $bids_dir $bids_dir/derivatives participant \
        --work-dir $work_dir \
        --participant_label "${sub##*/sub-}" \
        --output-spaces T1w \
        --level full \
        --skip-bids-validation \
        --fs-license-file "${fs_license}" \
        --cifti-output 91k

done

Version:

v23.2.1

Environment (Docker, Singularity / Apptainer, custom installation):

Singularity

Data formatted according to a validatable standard? Please provide the output of the validator:

(node:3405535) Warning: Closing directory handle on garbage collection
(Use `node --trace-warnings ...` to show where the warning was created)
	1: [ERR] Files with such naming scheme are not part of BIDS specification. This error is most commonly caused by typos in file names that make them not BIDS compatible. Please consult the specification and make sure your files are named correctly. If this is not a file naming issue (for example when including files not yet covered by the BIDS specification) you should include a ".bidsignore" file in your dataset (see https://github.com/bids-standard/bids-validator#bidsignore for details). Please note that derived (processed) data should be placed in /derivatives folder and source data (such as DICOMS or behavioural logs in proprietary formats) should be placed in the /sourcedata folder. (code: 1 - NOT_INCLUDED)
		./workdir/20240308-115051_1dd66bbb-0991-4e1a-8963-58816ade9c79/bids_db/layout_index.sqlite
			Evidence: layout_index.sqlite
		./workdir/workdir/20240317-160506_21007df4-ff40-4678-9d24-181851c71f74/bids_db/layout_index.sqlite
			Evidence: layout_index.sqlite
		./workdir/workdir/20240317-160512_cf2ac74e-7c38-4e1a-b1a0-56e27a0d631c/bids_db/layout_index.sqlite
			Evidence: layout_index.sqlite

	Please visit https://neurostars.org/search?q=NOT_INCLUDED for existing conversations about this issue.

	1: [WARN] Not all subjects contain the same files. Each subject should contain the same number of files with the same naming unless some files are known to be missing. (code: 38 - INCONSISTENT_SUBJECTS)
		./sub-SL002/func/sub-SL002_task-rest_bold.json
			Evidence: Subject: sub-SL002; Missing file: sub-SL002_task-rest_bold.json
		./sub-SL002/func/sub-SL002_task-rest_bold.nii.gz
			Evidence: Subject: sub-SL002; Missing file: sub-SL002_task-rest_bold.nii.gz
		./sub-SL002/func/sub-SL002_task-rest_events.tsv
			Evidence: Subject: sub-SL002; Missing file: sub-SL002_task-rest_events.tsv

	Please visit https://neurostars.org/search?q=INCONSISTENT_SUBJECTS for existing conversations about this issue.

	2: [WARN] Not all subjects/sessions/runs have the same scanning parameters. (code: 39 - INCONSISTENT_PARAMETERS)
		./sub-SL001/dwi/sub-SL001_dwi.nii.gz
		./sub-SL002/dwi/sub-SL002_dwi.nii.gz
		./sub-SL009/dwi/sub-SL009_dwi.nii.gz
		./sub-SL012/dwi/sub-SL012_dwi.nii.gz

	Please visit https://neurostars.org/search?q=INCONSISTENT_PARAMETERS for existing conversations about this issue.

	3: [WARN] Tabular file contains custom columns not described in a data dictionary (code: 82 - CUSTOM_COLUMN_WITHOUT_DESCRIPTION)
		./sub-SL001/func/sub-SL001_task-rest_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-rest_events.json,/sub-SL001/sub-SL001_events.json,/sub-SL001/sub-SL001_task-rest_events.json,/sub-SL001/func/sub-SL001_events.json,/sub-SL001/func/sub-SL001_task-rest_events.json
		./sub-SL001/func/sub-SL001_task-statlearning_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-statlearning_events.json,/sub-SL001/sub-SL001_events.json,/sub-SL001/sub-SL001_task-statlearning_events.json,/sub-SL001/func/sub-SL001_events.json,/sub-SL001/func/sub-SL001_task-statlearning_events.json
		./sub-SL002/func/sub-SL002_task-statlearning_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-statlearning_events.json,/sub-SL002/sub-SL002_events.json,/sub-SL002/sub-SL002_task-statlearning_events.json,/sub-SL002/func/sub-SL002_events.json,/sub-SL002/func/sub-SL002_task-statlearning_events.json
		./sub-SL003/func/sub-SL003_task-rest_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-rest_events.json,/sub-SL003/sub-SL003_events.json,/sub-SL003/sub-SL003_task-rest_events.json,/sub-SL003/func/sub-SL003_events.json,/sub-SL003/func/sub-SL003_task-rest_events.json
		./sub-SL003/func/sub-SL003_task-statlearning_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-statlearning_events.json,/sub-SL003/sub-SL003_events.json,/sub-SL003/sub-SL003_task-statlearning_events.json,/sub-SL003/func/sub-SL003_events.json,/sub-SL003/func/sub-SL003_task-statlearning_events.json
		./sub-SL004/func/sub-SL004_task-rest_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-rest_events.json,/sub-SL004/sub-SL004_events.json,/sub-SL004/sub-SL004_task-rest_events.json,/sub-SL004/func/sub-SL004_events.json,/sub-SL004/func/sub-SL004_task-rest_events.json
		./sub-SL004/func/sub-SL004_task-statlearning_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-statlearning_events.json,/sub-SL004/sub-SL004_events.json,/sub-SL004/sub-SL004_task-statlearning_events.json,/sub-SL004/func/sub-SL004_events.json,/sub-SL004/func/sub-SL004_task-statlearning_events.json
		./sub-SL005/func/sub-SL005_task-rest_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-rest_events.json,/sub-SL005/sub-SL005_events.json,/sub-SL005/sub-SL005_task-rest_events.json,/sub-SL005/func/sub-SL005_events.json,/sub-SL005/func/sub-SL005_task-rest_events.json
		./sub-SL005/func/sub-SL005_task-statlearning_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-statlearning_events.json,/sub-SL005/sub-SL005_events.json,/sub-SL005/sub-SL005_task-statlearning_events.json,/sub-SL005/func/sub-SL005_events.json,/sub-SL005/func/sub-SL005_task-statlearning_events.json
		./sub-SL006/func/sub-SL006_task-rest_events.tsv
			Evidence: Columns: TODO -- fill in rows and add more tab-separated columns if desired not defined, please define in: /events.json, /task-rest_events.json,/sub-SL006/sub-SL006_events.json,/sub-SL006/sub-SL006_task-rest_events.json,/sub-SL006/func/sub-SL006_events.json,/sub-SL006/func/sub-SL006_task-rest_events.json
		... and 27 more files having this issue (Use --verbose to see them all).

	Please visit https://neurostars.org/search?q=CUSTOM_COLUMN_WITHOUT_DESCRIPTION for existing conversations about this issue.

	4: [WARN] The recommended file /README is very small. Please consider expanding it with additional information about the dataset. (code: 213 - README_FILE_SMALL)
		./README

	Please visit https://neurostars.org/search?q=README_FILE_SMALL for existing conversations about this issue.

        Summary:                 Available Tasks:                             Available Modalities: 
        255 Files, 1.98GB        statlearning                                 MRI                   
        19 - Subjects            rest                                                               
        1 - Session              TODO: full task name for rest                                      
                                 TODO: full task name for statlearning                              


	If you have any questions, please post on https://neurostars.org/tags/bids.

This probably got lost in the refactor. What spaces were they resampled into? I can’t remember off the top of my head where they used to go.

They are pretty easy to pull out of FreeSurfer, though. Here you can resample in MNI with a particular BOLD run to ensure that your voxels align with that run:

mri_convert sourcedata/freesurfer/sub-XYZ/mri/aseg.{mgz,nii.gz}
antsApplyTransforms \
    -i sourcedata/freesurfer/sub-XYZ/mri/aseg.nii.gz \
    -r sub-XYZ/func/sub-XYZ_task-TASK_space-MNI152NLin2009cAsym_res-2_boldref.nii.gz \
    -o sub-XYZ_task-TASK_space-MNI152NLin2009cAsym_res-2_seg-aseg_dseg.nii.gz \
    -n GenericLabel \
    -t sub-XYZ/anat/sub-XYZ_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5 \
    -t sub-XYZ/anat/sub-XYZ_from-fsnative_to-T1w_mode-image_xfm.txt

If you want them in T1w space, you would do:

antsApplyTransforms \
    -i sourcedata/freesurfer/sub-XYZ/mri/aseg.nii.gz \
    -r sub-XYZ/func/sub-XYZ_task-TASK_space-T1w_res-2_boldref.nii.gz \
    -o sub-XYZ_task-TASK_space-T1w_seg-aseg_dseg.nii.gz \
    -n GenericLabel \
    -t sub-XYZ/anat/sub-XYZ_from-fsnative_to-T1w_mode-image_xfm.txt

Note that with ANTs, you pass the transform to the final target space first, and from the source space last.

1 Like

@effigies I will test this out, thanks. Is it a problem that I have /bids_root/sourcedata/... and /bids_root/derivatives/sourcedata/freesurfer/...?

Hi @Will_Decker,

Nope! /bids_root/sourcedata/... is for sourcedata for your raw data (e.g., your off-the-scanner DICOMS). Whereas /bids_root/derivatives/sourcedata/freesurfer/... is for sourcedata that go towards constructing derivatives. Having multiple instances of sourcedata is valid and should not confuse BIDS apps. fMRIPrep will default look for and create FreeSurfer outputs in /bids_root/derivatives/sourcedata/freesurfer/, but that can be changed with the --fs-subjects-dir argument.

Best,
Steven

2 Likes

@effigies I was able to successfully execute the commands you provided after some toying around with ther server I am operating on.

Sorry to reopen an old thread but I wanted to ask if there is any plan to include the missing files back in future implementations.

I’m asking because I developed a lightweight python tool that works in pipe with fmriprep, and I wouldn’t like it to depend on freesurfer/ants installations.

1 Like