MICA-MNI / micapipe

micapipe from the Multimodal imaging and connectome analysis lab (http://mica-mni.github.io) at the Montreal Neurological Institute. Read The Docs documentation below
http://micapipe.readthedocs.io
GNU General Public License v3.0
86 stars 29 forks source link

ANTs error #19

Closed ClaireSmid closed 3 years ago

ClaireSmid commented 3 years ago

I am running micapipe on my university's cluster, and I am getting a 'cannot stat' error when running proc-structural. This happens during the ANTs step. Running proc_structural therefore results in an error. I am trying to run proc_structural to completion.

I am using MobaXterm v20.3 build 4396 to tunnel into my university cluster from my work computer.

My BIDS format:

dataset/ rawdata/ sub-001/ ses-0/ anat/ sub-001_ses-0_run-1_T1w.nii sub-001_ses-0_run_1_T1w.json dwi/... fmap/... func/... ses-1/... derivatives/ freesurfer/ sub-001_ses-0/ label/ mri/ ... sub-001_ses-1/... micapipe/

Because I am not allowed to run sudo command on the cluster,

I pulled the docker image into a singularity wrapper:

# Create a .singularity directory in Scratch
mkdir $HOME/Scratch/.singularity 

# Create cache subdirectories we will use / export
mkdir $HOME/Scratch/.singularity/tmp
mkdir $HOME/Scratch/.singularity/localcache
mkdir $HOME/Scratch/.singularity/pull

# Set all the Singularity cache dirs to Scratch
export SINGULARITY_CACHEDIR=$HOME/Scratch/.singularity
export SINGULARITY_TMPDIR=$SINGULARITY_CACHEDIR/tmp
export SINGULARITY_LOCALCACHEDIR=$SINGULARITY_CACHEDIR/localcache
export SINGULARITY_PULLFOLDER=$SINGULARITY_CACHEDIR/pull

# Bind the data directory in Scratch so it is accessible from inside the container and the temporary storage jobs are allocated
# add after $USER
export SINGULARITY_BINDPATH=/scratch/scratch/$USER,/tmpdir

# to pull docker image
singularity pull docker://micalab/micapipe:latest

# Prints micapipe version / test commands can be used (this is equivalent to running mica-pipe command)
$SINGULARITY_PULLFOLDER/micapipe_latest.sif -v

below is the error report I get when running proc_structural

[ucjucrs@login12 MICA_BIDS]$ export SINGULARITY_CACHEDIR=$HOME/Scratch/.singularity
[ucjucrs@login12 MICA_BIDS]$ export SINGULARITY_TMPDIR=$SINGULARITY_CACHEDIR/tmp
[ucjucrs@login12 MICA_BIDS]$ export SINGULARITY_LOCALCACHEDIR=$SINGULARITY_CACHEDIR/localcache
[ucjucrs@login12 MICA_BIDS]$ export SINGULARITY_PULLFOLDER=$SINGULARITY_CACHEDIR/pull
[ucjucrs@login12 MICA_BIDS]$ export SINGULARITY_BINDPATH=/scratch/scratch/$USER/Struct_MRI/MICA_BIDS/,/tmpdir
[ucjucrs@login12 MICA_BIDS]$ $SINGULARITY_PULLFOLDER/micapipe_latest.sif -bids /home/ucjucrs/Scratch/Struct_MRI/MICA_BIDS/rawdata -out /home/ucjucrs/Scratch/Struct_MRI/MICA_BIDS/derivatives -sub 001 -ses 0 -proc_structural
WARNING: Bind mount '/home/ucjucrs => /home/ucjucrs' overlaps container CWD /home/ucjucrs/Scratch/Struct_MRI/MICA_BIDS, may not be available
Some packages in this Docker container are non-free
If you are considering commercial use of this container, please consult the relevant license:
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Licence
-------- freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0-2beb96c --------
Setting up environment for FreeSurfer/FS-FAST (and FSL)
FREESURFER_HOME   /opt/freesurfer-6.0.0
FSFAST_HOME       /opt/freesurfer-6.0.0/fsfast
FSF_OUTPUT_FORMAT nii.gz
SUBJECTS_DIR      /opt/freesurfer-6.0.0/subjects
MNI_DIR           /opt/freesurfer-6.0.0/mni
FSL_DIR           /opt/fsl-6.0.0

-------------------------------------------------------------
        MICA pipeline - (Version v0.1.1 'Roadrunner')
                Subject: 001 Session: ses-0
-------------------------------------------------------------

[ WARNING ]..... fix was not found, ICA-FIX will be skipped

[ INFO ]..... micapipe will use 6 threads for multicore processing

[ INFO ]..... Subject 001 directory exist

[ INFO ]..... sub-001 directory structure:

/scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0
├── anat
│   ├── first
│   ├── surfaces
│   │   └── conte69
│   └── volumetric
├── dwi
├── func
├── logs
├── QC
│   └── png
└── xfm

11 directories

-------------------------------------------------------------
        Structural processing
                micapipe v0.1.1 'Roadrunner', LOCAL
-------------------------------------------------------------

[ INFO ]..... MICA pipe - Software versions
                MRtrix3.....    3.0.1
                                /opt/miniconda-latest/envs/micapipe/bin/mrinfo
                FSL.........    6.0
                                /opt/fsl-6.0.0
                ANFI........     Aug 22 2021 (Version AFNI_21.2.05 'Nerva')
                                /opt/afni-latest/3dresample
                ANTS........     2.3.3.dev168-g29bdf
                                /opt/ants-2.3.4
                WorkBench...    1.3.2
                                /usr/bin/wb_command
                FreeSurfer..    freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0-2beb96c
                                /opt/freesurfer-6.0.0
                fix.........
                                /opt/fix
                python......    Python 3.7.10
                                /opt/miniconda-latest/envs/micapipe/bin/python
                R...........    3.6.3
                                /usr/bin/R

[ INFO ]..... mica-pipe inputs:
                id   =  001
                BIDS =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/rawdata
                out  =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe
                ses  =  ses-0

[ INFO ]..... BIDS naming:
                subject_bids =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/rawdata/sub-001/ses-0
                bids_T1ws    =  N-1, e.g. /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/rawdata/sub-001/ses-0/anat/sub-001_ses-0_run-1_T1w.nii
                bids_dwis    =  N-0, e.g.
                subject      =  sub-001
                subject_dir  =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0
                proc_struct  =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/anat
                dir_warp     =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/xfm
                logs         =  /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/logs

[ INFO ]..... Processing directories:
                subject_dir     =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0
                proc_struct     =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/anat
                dir_conte69     =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/anat/surfaces/conte69
                dir_volum       =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/anat/volumetric
                dir_warp        =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/xfm
                dir_logs        =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/logs
                dir_QC          =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/QC
                dir_freesurfer  =       /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/freesurfer/sub-001_ses-0

[ INFO ]..... Utilities directories:
                scriptDir         =     /opt/micapipe/functions
                util_MNIvolumes   =     /opt/micapipe/MNI152Volumes
                util_lut          =     /opt/micapipe/parcellations/lut
                util_parcelations =     /opt/micapipe/parcellations
                util_surface      =     /opt/micapipe/surfaces
                util_mics         =     /opt/micapipe/MICs60_T1-atlas

[ INFO ]..... Saving temporal dir: FALSE

[ INFO ]..... ANTs will use 6 threads

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:17 BST 2021:
COMMAND -->   mkdir -p /tmp/30415_micapipe_proc_struc-vol_001

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:17 BST 2021:
COMMAND -->   3dresample -orient LPI -prefix /tmp/30415_micapipe_proc_struc-vol_001/obl-001_ses-0_run-1_T1w.nii -inset /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/rawdata/sub-001/ses-0/anat/sub-001_ses-0_run-1_T1w.nii

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:17 BST 2021:
COMMAND -->   fslreorient2std /tmp/30415_micapipe_proc_struc-vol_001/obl-001_ses-0_run-1_T1w.nii /tmp/30415_micapipe_proc_struc-vol_001/reo-001_ses-0_run-1_T1w.nii

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:20 BST 2021:
COMMAND -->   cp -v /tmp/30415_micapipe_proc_struc-vol_001/reo-001_ses-0_run-1_T1w.nii /tmp/30415_micapipe_proc_struc-vol_001/sub-001_ses-0_space-nativepro_t1w_n4.nii.gz
cp: cannot stat '/tmp/30415_micapipe_proc_struc-vol_001/reo-001_ses-0_run-1_T1w.nii': No such file or directory

[ INFO ]..... T1w_nativepro biasfield correction and intensity rescaling

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:20 BST 2021:
COMMAND -->   N4BiasFieldCorrection -d 3 -i /tmp/30415_micapipe_proc_struc-vol_001/sub-001_ses-0_space-nativepro_t1w_n4.nii.gz -r -o /tmp/30415_micapipe_proc_struc-vol_001/sub-001_ses-0_space-nativepro_t1w_n4.nii.gz -v

Running N4 for 3-dimensional images.

 file /tmp/30415_micapipe_proc_struc-vol_001/sub-001_ses-0_space-nativepro_t1w_n4.nii.gz does not exist .
Mask not read.  Using the entire image as the mask.

/opt/micapipe/functions/utilities.sh: line 584: 95445 Segmentation fault      $l_command

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:20 BST 2021:
COMMAND -->   ImageMath 3 /scratch/scratch/ucjucrs/Struct_MRI/MICA_BIDS/derivatives/micapipe/sub-001/ses-0/anat/sub-001_ses-0_space-nativepro_t1w.nii.gz RescaleImage /tmp/30415_micapipe_proc_struc-vol_001/sub-001_ses-0_space-nativepro_t1w_n4.nii.gz 0 100
 file /tmp/30415_micapipe_proc_struc-vol_001/sub-001_ses-0_space-nativepro_t1w_n4.nii.gz does not exist .
terminate called after throwing an instance of 'itk::ExceptionObject'
  what():  /src/ants/build/ITKv5/Modules/Core/Common/src/itkProcessObject.cxx:1340:
itk::ERROR: RescaleIntensityImageFilter(0x43cfa80): Input Primary is required but not set.
/opt/micapipe/functions/utilities.sh: line 584: 95486 Aborted                 $l_command

-------------------------------------------------------------

[ ERROR ]..... sub-001_ses-0_space-nativepro_t1w was not generated

-------------------------------------------------------------

ucjucrs @ login12.myriad.ucl.ac.uk Thu Sep 30 10:47:20 BST 2021:
COMMAND -->   exit
Erasing temporal directory: /tmp/*_micapipe*_001
OLD_PATH is unset or empty

-------------------------------------------------------------
        GLOBAL micapipe running time with LOCAL processing: 0.083 minutes
-------------------------------------------------------------
rcruces commented 3 years ago

Hi Claire, thank you for your comments. We noticed this behavior when the raw data is in nifti format instead of nii.gz, it was fixed on this commit https://github.com/MICA-MNI/micapipe/commit/469eb3e83126fa2407262e91c60d9c43d79989c5 And now it's in the lates version of the docker. It should work, but please keep me informed! Best