bids-apps / MRtrix3_connectome

Generate subject connectomes from raw BIDS data & perform inter-subject connection density normalisation, using the MRtrix3 software package.
http://www.mrtrix.org/
Apache License 2.0
49 stars 26 forks source link

Trouble with participant level #90

Closed dkp closed 2 years ago

dkp commented 3 years ago

Hi Robert, I'm feeling dumb here. The summary is, I ran the preproc level with no issue, but at the participant level, the container cannot find the relevant data. I've tried specifying the session and not specifying it (figuring it would do everything it found if I did not specify...consistent with the preproc step).

The preproc stage created appropriate looking files:

dkp@login:derivatives$ ls -R MRtrix3_connectome-preproc/

MRtrix3_connectome-preproc/:
sub-219

MRtrix3_connectome-preproc/sub-219:
ses-itbs

MRtrix3_connectome-preproc/sub-219/ses-itbs:
anat  dwi

MRtrix3_connectome-preproc/sub-219/ses-itbs/anat:
sub-219_ses-itbs_desc-brain_mask.nii.gz  sub-219_ses-itbs_desc-preproc_T1w.json  sub-219_ses-itbs_desc-preproc_T1w.nii.gz

MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi:
eddyqc  sub-219_ses-itbs_desc-brain_mask.nii.gz  sub-219_ses-itbs_desc-preproc_dwi.bval  sub-219_ses-itbs_desc-preproc_dwi.bvec  sub-219_ses-itbs_desc-preproc_dwi.json  sub-219_ses-itbs_desc-preproc_dwi.nii.gz

MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/eddyqc:
eddy_movement_rms  eddy_outlier_map  eddy_outlier_n_sqr_stdev_map  eddy_outlier_n_stdev_map  eddy_outlier_report  eddy_parameters  eddy_post_eddy_shell_alignment_parameters  eddy_post_eddy_shell_PE_translation_parameters  eddy_restricted_movement_rms  quad

MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/eddyqc/quad:
avg_b0_pe0.png  avg_b0.png  avg_b1000.png  qc.json  qc.pdf  ref_list.png  ref.txt  vdm.png
dkp@login:derivatives$ ls -R1 MRtrix3_connectome-preproc/
MRtrix3_connectome-preproc/:
sub-219

MRtrix3_connectome-preproc/sub-219:
ses-itbs

MRtrix3_connectome-preproc/sub-219/ses-itbs:
anat
dwi

MRtrix3_connectome-preproc/sub-219/ses-itbs/anat:
sub-219_ses-itbs_desc-brain_mask.nii.gz
sub-219_ses-itbs_desc-preproc_T1w.json
sub-219_ses-itbs_desc-preproc_T1w.nii.gz

MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi:
eddyqc
sub-219_ses-itbs_desc-brain_mask.nii.gz
sub-219_ses-itbs_desc-preproc_dwi.bval
sub-219_ses-itbs_desc-preproc_dwi.bvec
sub-219_ses-itbs_desc-preproc_dwi.json
sub-219_ses-itbs_desc-preproc_dwi.nii.gz

MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/eddyqc:
eddy_movement_rms
eddy_outlier_map
eddy_outlier_n_sqr_stdev_map
eddy_outlier_n_stdev_map
eddy_outlier_report
eddy_parameters
eddy_post_eddy_shell_alignment_parameters
eddy_post_eddy_shell_PE_translation_parameters
eddy_restricted_movement_rms
quad

MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/eddyqc/quad:
avg_b0_pe0.png
avg_b0.png
avg_b1000.png
qc.json
qc.pdf
ref_list.png
ref.txt
vdm.png

Participant Level

Next, I tried the participant stage several times, both with and without specifying the session.

singularity run --cleanenv --bind /groups/dkp/Nifti:/bids_dataset --bind /groups/dkp/Nifti/derivatives:/outputs ${SIF}/mrtrix3_connectome.sif /bids_dataset /outputs participant --participant_label 219 --session_label itbs --scratch  /groups/dkp/mrtrix_scratch --parcellation hcpmmp1 --output_verbosity 3

Within seconds, I get the following log:

(note that it believes there are 2 sessions, but there is only one session...but mostly, it cannot find the data to work on)

cat mrtrix3_0.5_participant_hcpmmp1.o211703
mrtrix3_connectome.py: 
mrtrix3_connectome.py: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
mrtrix3_connectome.py: 
Command:  bids-validator /bids_dataset
mrtrix3_connectome.py: 2 total sessions found in directory '/bids_dataset'; all will be processed
mrtrix3_connectome.py: Commencing execution for session: 'derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs'
mrtrix3_connectome.py: Generated scratch directory: /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-UCNN9M/
mrtrix3_connectome.py: Importing pre-processed data into scratch directory
Command:  mrconvert /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.nii.gz /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-UCNN9M/dwi.mif -fslgrad /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.bvec /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.bval -strides 0,0,0,1
Command:  mrconvert /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-UCNN9M/dwi_mask.mif -datatype bit

mrtrix3_connectome.py: [ERROR] Unable to import requisite pre-processed data from either specified input directory or MRtrix3_connectome output directory
Error when attempting load from "/bids_dataset":
No raw or pre-processed T1-weighted images could be found in input directory "/bids_dataset" for session derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs
Error when attempting load from "/outputs/MRtrix3_connectome-preproc":
No DWIs found for session "derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs"

Debug Mode

mrtrix3_connectome.py: 
mrtrix3_connectome.py: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
mrtrix3_connectome.py: 
mrtrix3_connectome.py: [DEBUG] run.exe_name() (from run.py:339): bids-validator -> bids-validator
mrtrix3_connectome.py: [DEBUG] run.version_match() (from run.py:566): Command bids-validator not found in MRtrix3 bin/ directory
mrtrix3_connectome.py: [DEBUG] run.exe_name() (from run.py:568): bids-validator -> bids-validator
mrtrix3_connectome.py: [DEBUG] run._shebang() (from run.py:340): File "bids-validator": string "#!/usr/bin/env node": ['/usr/bin/env', 'node']
mrtrix3_connectome.py: [DEBUG] run.command() (from mrtrix3_connectome.py:4080): To execute: [['/usr/bin/env', 'node', '/usr/bin/bids-validator', '/bids_dataset']]
Command:  bids-validator /bids_dataset
mrtrix3_connectome.py: [DEBUG] mrtrix3_connectome.get_sessions() (from mrtrix3_connectome.py:4110): ['derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs', 'sub-219/ses-itbs']
mrtrix3_connectome.py: 2 total sessions found in directory '/bids_dataset'; all will be processed
mrtrix3_connectome.py: [DEBUG] mrtrix3_connectome.get_sessions() (from mrtrix3_connectome.py:4110): [['derivatives', 'MRtrix3_connectome-preproc', 'sub-219', 'ses-itbs'], ['sub-219', 'ses-itbs']]
mrtrix3_connectome.py: [DEBUG] fsl.exe_name() (from mrtrix3_connectome.py:40): /opt/fsl/bin/fsl_anat
mrtrix3_connectome.py: [DEBUG] mrtrix3_connectome.__init__() (from mrtrix3_connectome.py:4135):  -parallel
mrtrix3_connectome.py: [DEBUG] mrtrix3_connectome.__init__() (from mrtrix3_connectome.py:4135): Using softlinks to FreeSurfer template directories
mrtrix3_connectome.py: Commencing execution for session: 'derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs'
mrtrix3_connectome.py: Generated scratch directory: /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/
mrtrix3_connectome.py: Importing pre-processed data into scratch directory
mrtrix3_connectome.py: [DEBUG] path.to_scratch() (from mrtrix3_connectome.py:2040): dwi.mif -> /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi.mif
mrtrix3_connectome.py: [DEBUG] run.exe_name() (from run.py:546): mrconvert -> mrconvert
mrtrix3_connectome.py: [DEBUG] run.version_match() (from run.py:330): Version-matched executable for mrconvert: /opt/mrtrix3/bin/mrconvert
mrtrix3_connectome.py: [DEBUG] run._shebang() (from run.py:340): File "/opt/mrtrix3/bin/mrconvert": Not a text file
mrtrix3_connectome.py: [DEBUG] run.command() (from mrtrix3_connectome.py:2040): To execute: [['/opt/mrtrix3/bin/mrconvert', '/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.nii.gz', '/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi.mif', '-fslgrad', '/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.bvec', '/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.bval', '-strides', '0,0,0,1', '-info']]
Command:  mrconvert /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.nii.gz /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi.mif -fslgrad /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.bvec /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.bval -strides 0,0,0,1
          mrconvert: [INFO] opening image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.nii.gz"...
          mrconvert: [INFO] image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.nii.gz" opened with dimensions 70x94x74x32, voxel spacing 2x2x2x11.5, datatype Float32LE
          mrconvert: [INFO] found 32x4 diffusion gradient table
          mrconvert: [100%] uncompressing image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-preproc_dwi.nii.gz"
          mrconvert: [INFO] opening image "0,0,0,1"...
          mrconvert: [INFO] creating image "/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi.mif"...
          mrconvert: [INFO] image "/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi.mif" created with dimensions 70x94x74x32, voxel spacing 2x2x2x11.5, datatype Float32LE
          mrconvert: [100%] copying from "/bids_data...tbs_desc-preproc_dwi.nii.gz" to "/groups/dk...ctome.py-tmp-THO5EH/dwi.mif"
          mrconvert: [INFO] writing back contents of mapped file "/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi.mif"...
mrtrix3_connectome.py: [DEBUG] path.to_scratch() (from mrtrix3_connectome.py:2047): dwi_mask.mif -> /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi_mask.mif
mrtrix3_connectome.py: [DEBUG] run.exe_name() (from run.py:546): mrconvert -> mrconvert
mrtrix3_connectome.py: [DEBUG] run.version_match() (from run.py:330): Version-matched executable for mrconvert: /opt/mrtrix3/bin/mrconvert
mrtrix3_connectome.py: [DEBUG] run._shebang() (from run.py:340): File "/opt/mrtrix3/bin/mrconvert": Not a text file
mrtrix3_connectome.py: [DEBUG] run.command() (from mrtrix3_connectome.py:2047): To execute: [['/opt/mrtrix3/bin/mrconvert', '/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz', '/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi_mask.mif', '-datatype', 'bit', '-info']]
Command:  mrconvert /bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi_mask.mif -datatype bit
          mrconvert: [INFO] opening image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz"...
          mrconvert: [INFO] image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz" opened with dimensions 70x94x74, voxel spacing 2x2x2, datatype UInt8
          mrconvert: [INFO] no valid diffusion gradient table found
          mrconvert: [INFO] error importing diffusion gradient table for image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz"
          mrconvert: [done] uncompressing image "/bids_dataset/derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs/dwi/sub-219_ses-itbs_desc-brain_mask.nii.gz"
          mrconvert: [INFO] creating image "/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi_mask.mif"...
          mrconvert: [INFO] image "/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi_mask.mif" created with dimensions 70x94x74, voxel spacing 2x2x2, datatype Bit
          mrconvert: [100%] copying from "/bids_data...itbs_desc-brain_mask.nii.gz" to "/groups/dk....py-tmp-THO5EH/dwi_mask.mif"
          mrconvert: [INFO] writing back contents of mapped file "/groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/dwi_mask.mif"...

mrtrix3_connectome.py: [ERROR] Unable to import requisite pre-processed data from either specified input directory or MRtrix3_connectome output directory
Error when attempting load from "/bids_dataset":
No raw or pre-processed T1-weighted images could be found in input directory "/bids_dataset" for session derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs
Error when attempting load from "/outputs/MRtrix3_connectome-preproc":
No DWIs found for session "derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs"
mrtrix3_connectome.py: Scratch directory retained; location: /groups/dkp/mrtrix_scratch/mrtrix3_connectome.py-tmp-THO5EH/
Lestropie commented 3 years ago

(note that it believes there are 2 sessions, but there is only one session...but mostly, it cannot find the data to work on)

This indicates that it believes that there is a total of two sessions within the BIDS dataset across all subjects, not necessarily two sessions within the one subject. But the answer to this is below.

Error when attempting load from "/bids_dataset":
No raw or pre-processed T1-weighted images could be found in input directory "/bids_dataset" for session derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs

There is an issue arising here somehow in the parsing of session information. The session name should be "sub-219_ses-itbs", but instead the parent directories are being accumulated into such for some reason. This can be seen here:

mrtrix3_connectome.py: [DEBUG] mrtrix3_connectome.get_sessions() (from mrtrix3_connectome.py:4110): ['derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs', 'sub-219/ses-itbs']

I'm thinking one possibility here is that you have created the "derivatives" directory as a sub-directory of the input BIDS dataset, as can be seen in your singularity run call:

... --bind /groups/dkp/Nifti:/bids_dataset --bind /groups/dkp/Nifti/derivatives:/outputs ...

This I would have expected to result in the BIDS validator failing. A quick search suggests that the BIDS validator may have been hard-coded to ignore the contents of any derivatives/ sub-directory from root, in which case it's been deemed permissible and my code probably needs to do the same. I also seem to recall having had a discussion with the BIDS crew regarding what relative filesystem arrangements between raw and derived data should be permitted or not, though I'm having trouble finding it. For instance, the BIDS raw directory would ideally be mounted read-only by an application, and so having the output being written to a sub-directory of such is counter-intuitive to me personally.

So at your end, I would suggest placing your "derivatives" directory somewhere other than within the BIDS raw directory, as this seems to be confusing my session parsing code.

dkp commented 3 years ago

It appears to be running after moving the derivatives directory... I do get your point about it being kind of weird to put derivatives inside a read-only directory..

Thanks for your support, -Dianne

Dianne Patterson, Ph.D Speech, Language and Hearing Sciences, Room 314 dkp@arizona.edu


From: Robert Smith notifications@github.com Sent: Monday, November 16, 2020 6:38 PM To: BIDS-Apps/MRtrix3_connectome MRtrix3_connectome@noreply.github.com Cc: Patterson, Dianne K - (dkp) dkp@arizona.edu; Author author@noreply.github.com Subject: [EXT]Re: [BIDS-Apps/MRtrix3_connectome] Trouble with participant level (#90)

External Email

(note that it believes there are 2 sessions, but there is only one session...but mostly, it cannot find the data to work on)

This indicates that it believes that there is a total of two sessions within the BIDS dataset across all subjects, not necessarily two sessions within the one subject. But the answer to this is below.

Error when attempting load from "/bids_dataset": No raw or pre-processed T1-weighted images could be found in input directory "/bids_dataset" for session derivatives_MRtrix3_connectome-preproc_sub-219_ses-itbs

There is an issue arising here somehow in the parsing of session information. The session name should be "sub-219_ses-itbs", but instead the parent directories are being accumulated into such for some reason. This can be seen here:

mrtrix3_connectome.py: [DEBUG] mrtrix3_connectome.get_sessions() (from mrtrix3_connectome.py:4110): ['derivatives/MRtrix3_connectome-preproc/sub-219/ses-itbs', 'sub-219/ses-itbs']

I'm thinking one possibility here is that you have created the "derivatives" directory as a sub-directory of the input BIDS dataset, as can be seen in your singularity run call:

... --bind /groups/dkp/Nifti:/bids_dataset --bind /groups/dkp/Nifti/derivatives:/outputs ...

This I would have expected to result in the BIDS validator failing. A quick search suggests that the BIDS validator may have been hard-coded to ignore the contents of any derivatives/ sub-directory from root, in which case it's been deemed permissible and my code probably needs to do the same. I also seem to recall having had a discussion with the BIDS crew regarding what relative filesystem arrangements between raw and derived data should be permitted or not, though I'm having trouble finding it. For instance, the BIDS raw directory would ideally be mounted read-only by an application, and so having the output being written to a sub-directory of such is counter-intuitive to me personally.

So at your end, I would suggest placing your "derivatives" directory somewhere other than within the BIDS raw directory, as this seems to be confusing my session parsing code.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BIDS-Apps/MRtrix3_connectome/issues/90#issuecomment-728629863, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHLUQC4W5G7PFVJH4QCCZ3SQHH3FANCNFSM4TXQVR7A.

Lestropie commented 3 years ago

In case it helps me find the information I'm looking for: were you following any specific instruction when you made the derivatives/ directory inside the BIDS raw dataset? While I can make changes to the code that would support such a filesystem arrangement, I'd prefer such a change to be driven by either current or future BIDS specification.

dkp commented 3 years ago

I have just settled on the derivatives inside the bids dir as a standard approach...I have not had a reason to change until now.

Are you looking for something like this:

https://bids-specification.readthedocs.io/en/latest/02-common-principles.html#storage-of-derived-datasets

Alternatively one can organize their data in the following way

my_dataset/ sourcedata/ ... rawdata/ dataset_description.json participants.tsv sub-01/ sub-02/ ... derivatives/ pipeline_1/ pipeline_2/ ...

In this example, where sourcedata and derivatives are not nested inside rawdata, only the rawdata subfolder needs to be a BIDS-compliant dataset. The subfolders of derivativesMAY be BIDS-compliant derivatives datasets (see Non-compliant derivativeshttps://bids-specification.readthedocs.io/en/latest/02-common-principles.html#non-compliant-derivatives for further discussion). This specification does not prescribe anything about the contents of sourcedatafolders in the above example - nor does it prescribe the sourcedata, derivatives, or rawdatafolder names. The above example is just a convention that can be useful for organizing raw, source, and derived data while maintaining BIDS compliancy of the raw data folder. When using this convention it is RECOMMENDED to set the SourceDatasets field in dataset_description.json of each subfolder of derivatives to:

Get Outlook for iOShttps://aka.ms/o0ukef


From: Robert Smith notifications@github.com Sent: Monday, November 16, 2020 8:32:14 PM To: BIDS-Apps/MRtrix3_connectome MRtrix3_connectome@noreply.github.com Cc: Patterson, Dianne K - (dkp) dkp@arizona.edu; Author author@noreply.github.com Subject: [EXT]Re: [BIDS-Apps/MRtrix3_connectome] Trouble with participant level (#90)

External Email

In case it helps me find the information I'm looking for: were you following any specific instruction when you made the derivatives/ directory inside the BIDS raw dataset? While I can make changes to the code that would support such a filesystem arrangement, I'd prefer such a change to be driven by either current or future BIDS specification.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BIDS-Apps/MRtrix3_connectome/issues/90#issuecomment-728664171, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHLUQF42O5O63DYNXVKMQLSQHVD5ANCNFSM4TXQVR7A.