nipreps / smriprep

Structural MRI PREProcessing (sMRIPrep) workflows for NIPreps (NeuroImaging PREProcessing tools)
https://nipreps.github.io/smriprep
Apache License 2.0
134 stars 39 forks source link

Missing fsLR surface files in the derivatives folder despite specifying fsLR in --output-space #454

Closed zhitao-guo closed 1 month ago

zhitao-guo commented 1 month ago

What happened?

The fsLR surface files (e.g. pial, white, midthickness) are missing in the derivatives/sub/anat folder, even though I specified fsLR in the --output-space option.

What command did you use?

docker run --name "$subj" \
--user "$(id -u):$(id -g)" \
-v $DATA_DIR:/data:ro \
-v $RESULTS_DIR:/out \
-v $DATA_DIR/license.txt:/opt/freesurfer_license/license.txt \
-v $WORK_DIR:/work \
nipreps/fmriprep:${FMRIPREP_VERSION} /data /out participant \
--skip_bids_validation \
--participant-label ${subj} \
--ignore slicetiming \
--output-space anat fsaverage fsnative MNI152NLin2009cAsym fsLR \
--fs-license-file /opt/freesurfer_license/license.txt \
--cifti-output 91k \
--bold2t1w-dof 12 \
--nthreads $nthreads \
--n-cpus $ncpus \
--stop-on-first-crash \
--work-dir /work \
--resource-monitor \
--write-graph \
--debug all

What version of fMRIPrep are you running?

24.0.0

How are you running fMRIPrep?

Docker

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Additional information

The issus is similar to the post: https://neurostars.org/t/fmriprep-20-2-7-no-fslr-outputs/23532. I inspected the intermediate results file and I noticed that there are two important files under the folder /work/fmriprep_24_0_wf/sub_100307_wf/resample_midthickness_wf/resampler/mapflow/_resampler0:

effigies commented 1 month ago

Moved to smriprep, as structural derivatives are/will be handled there. In general, it hasn't been assumed that people are interested in resampling template meshes back into the subject space.

To be clear, you want the fsLR mesh in the subject's space? This would allow you to do something like plot how group results appear on an individual subject's cortical folding pattern.

That type of mesh what is produced in the command you show:

wb_command -surface-resample /work/fmriprep_24_0_wf/sub_100307_wf/anat_fit_wf/gifti_surface_wf/fix_surfs/mapflow/_fix_surfs4/lh.midthickness_converted.gii \
/out/sub-100307/anat/sub-100307_hemi-L_space-fsLR_desc-msmsulc_sphere.surf.gii \
/home/fmriprep/.cache/templateflow/tpl-fsLR/tpl-fsLR_hemi-L_den-32k_sphere.surf.gii \
BARYCENTRIC lh.midthickness_converted_resampled.surf.gii

The file lh.midthickness_converted_resampled.surf.gii is the exact one that has been resampled into the fsLR space.

What we have here is the left fsLR mesh, reproduced along with a set of coordinates that place the mesh vertices on the surface described by the subject's left midthickness surface. Which to me seems like the opposite of what you describe. The coordinates are now meaningful in the context of the subject's anatomy, but the vertices are topologically identical to those in which fsLR metrics (BOLD series, thickness, etc) are located on.

Irritatingly, "space" is a murky term when working with surfaces. Surfaces have a triangular mesh that defines the relationship of vertices, and a coordinate array that provides RAS coordinates for those vertices. Those coordinates are in a volumetric space. We use "fsLR" to mean the fsLR meshes, and that is abstracted from any particular volumetric space (as are all template meshes), although there do exist coordinates, usually in MNI space, that make the meshes look like brains. Conte69 is an example.

Additionally, if I replace midthickness with pial and white in the command.txt, can I obtain the corresponding pial/white cortical surface files in fsLR space?

Yes.

For volume-based fMRI data, the time series of every voxel corresponds to a spatial coordinate. And for surface-based fMRI data (in fsnative, fsaverage or fsLR space), if I have a time series for a specific vertex, how to find its corresponding vertex coordinates?

You need to select a particular surface, and then you can look up a particular vertex in the surface coordinate array. For example, you can read the fsaverage/surf/lh.pial. Vertex N will be the Nth (0-indexed) row in the coordinate array. If you have the fsLR mesh sampled into the fsnative space (which is what you're asking for), then you would look up the Nth row in that coordinate array to find the subject-specific coordinate, or perhaps the Conte69 atlas to find an MNI coordinate.

Is that coordinate meaningful? Maybe, but more likely it's intended to be a proxy for anatomical structure. You will want to use an atlas parcellation that is relevant to your study to determine the structure that the vertex or voxel is found in.


Incidentally, this is why I haven't seen a particular necessity to output template meshes resampled into subject space. They're easy enough to create if you want, but their interpretation is subtle.

Still, it would not be too hard to create these and output them, and they're relatively cheap compared to BOLD.

@tsalo I'm curious about your thoughts. I believe we discussed this in the past and I can't remember if we said we'd do it...

tsalo commented 1 month ago

I did request this in #447. Currently XCP-D does this step but almost all of the same steps are already applied in sMRIPrep for different purposes.

EDIT: AFAICT the only use-case for these files is visualization, but it is probably better to visualize fsLR-space derivatives on the subject's morphology than on fsLR.

effigies commented 1 month ago

Ah, thank you for looking (counts...) 7 whole issues down the list.

Closing as duplicate.