shnizzedy / mindboggle

Automated anatomical brain label/shape analysis software (+ website)
http://mindboggle.info
Other
0 stars 0 forks source link

🎯 Run mindboggle123 without errors #4

Open shnizzedy opened 3 years ago

shnizzedy commented 3 years ago

Command:

singularity run \
  -B $LOCAL_DATAPATH/.git:/.git \
  -B $LOCAL_DATAPATH/$SUBJECT/$SESSION/anat:/home/jovyan/work \
  -B $LOCAL_DATAPATH/$SUBJECT/$SESSION/anat:/home/jovyan/work:ro \
  -B $LOCAL_OUTPATH:/MBoutput -e  \
  mindboggle.simg \
  mindboggle123 \
  /home/jovyan/work/$SUBJECT_$SESSION_acq-refaced_T1w.nii.gz \
  --out /MBoutput \
  --working /MBoutput/working \
  --id $SUBJECT \
  --plugin MultiProc --plugin_args "dict(n_procs=4,memory_gb=15)"  --fs_openmp 4 --ants_num_threads 4 --mb_num_threads 4
shnizzedy commented 3 years ago

Currently running

curl -LOJ https://osf.io/k3m94/?action=download&version=1
unzip example_mri_data.zip
HOST=$PWD
DOCK=/home/jovyan/work
IMAGE=$DOCK/example_mri_data/T1.nii.gz
ID=arno
OUT=$DOCK/mindboggle123_output
docker run --rm -it -v $HOST:$DOCK docker.pkg.github.com/shnizzedy/mindboggle/mindboggle:refs_tags_github-action mindboggle123 $IMAGE --id $ID

based on the instructions here.

Also building mindboggle.simg from this Singularity recipe and running

curl -LOJ https://osf.io/k3m94/?action=download&version=1
unzip example_mri_data.zip
HOST=$PWD
DOCK=/home/jovyan/work
IMAGE=$DOCK/example_mri_data/T1.nii.gz
ID=arno
SINGULARITY_OUT=$DOCK/mindboggle123_singularity_output
singularity run \
  -B $HOST:$DOCK \
  mindboggle.simg \
  mindboggle123 \
  $IMAGE \
  --out $SINGULARITY_OUT \
  --working $SINGULARITY_OUT/working \
  --id $ID \
  --plugin MultiProc --plugin_args "dict(n_procs=4,memory_gb=15)"  --fs_openmp 4 --ants_num_threads 4 --mb_num_threads 4

to get closer to running the original command in question.

If both succeed error-free, then I'll try to get close to the original environment of the original command. Otherwise, I'll post the error(s) as issues and continue debugging.

shnizzedy commented 3 years ago

This seems to be the remaining trouble here.

shnizzedy commented 3 years ago

After a bit more digging, for me the surprising environment variables (e.g., the ones starting with /usr/local/freesurfer) were coming from my host environment. Starting a container with --cleanenv (singularity run --cleanenv) avoids the issue entirely. ― https://github.com/ReproNim/neurodocker/issues/321#issuecomment-812522832

shnizzedy commented 3 years ago

Lei noticed too few files in his freesurfer_subjects outputs directory when running in Singularity, and I confirmed that I see the same behavior:

DockerSingularity
```tree freesurfer_subjects/ └── arno ├── label │   ├── lh.cortex.label │   └── rh.cortex.label ├── mri │   ├── aseg.auto.mgz │   ├── aseg.auto_noCCseg.label_intensities.txt │   ├── aseg.auto_noCCseg.mgz │   ├── aseg.presurf.mgz │   ├── brain.finalsurfs.mgz │   ├── brainmask.auto.mgz │   ├── brainmask.mgz │   ├── brain.mgz │   ├── ctrl_pts.mgz │   ├── filled.mgz │   ├── mri_nu_correct.mni.log │   ├── mri_nu_correct.mni.log.bak │   ├── norm.mgz │   ├── nu.mgz │   ├── orig │   │   └── 001.mgz │   ├── orig.mgz │   ├── orig_nu.mgz │   ├── rawavg.mgz │   ├── segment.dat │   ├── T1.mgz │   ├── talairach.label_intensities.txt │   ├── talairach.log │   ├── talairach_with_skull.log │   ├── transforms │   │   ├── bak │   │   ├── cc_up.lta │   │   ├── talairach.auto.xfm │   │   ├── talairach.auto.xfm.lta │   │   ├── talairach_avi.log │   │   ├── talairach_avi_QA.log │   │   ├── talairach.lta │   │   ├── talairach.m3z │   │   ├── talairach_with_skull.lta │   │   ├── talairach.xfm │   │   └── talsrcimg_to_711-2C_as_mni_average_305_t4_vox2vox.txt │   ├── wm.asegedit.mgz │   ├── wm.mgz │   └── wm.seg.mgz ├── scripts │   ├── build-stamp.txt │   ├── IsRunning.lh+rh │   ├── lastcall.build-stamp.txt │   ├── patchdir.txt │   ├── ponscc.cut.log │   ├── recon-all.cmd │   ├── recon-all.env │   ├── recon-all.local-copy │   ├── recon-all.log │   └── recon-all-status.log ├── stats │   ├── lh.curv.stats │   └── rh.curv.stats ├── surf │   ├── lh.area │   ├── lh.curv │   ├── lh.defect_borders │   ├── lh.defect_chull │   ├── lh.defect_labels │   ├── lh.inflated │   ├── lh.inflated.H │   ├── lh.inflated.K │   ├── lh.inflated.nofix │   ├── lh.orig │   ├── lh.orig.nofix │   ├── lh.qsphere.nofix │   ├── lh.smoothwm │   ├── lh.smoothwm.BE.crv │   ├── lh.smoothwm.C.crv │   ├── lh.smoothwm.FI.crv │   ├── lh.smoothwm.H.crv │   ├── lh.smoothwm.K1.crv │   ├── lh.smoothwm.K2.crv │   ├── lh.smoothwm.K.crv │   ├── lh.smoothwm.nofix │   ├── lh.smoothwm.S.crv │   ├── lh.sulc │   ├── lh.white.H -> lh.white.preaparc.H │   ├── lh.white.K -> lh.white.preaparc.K │   ├── lh.white.preaparc │   ├── lh.white.preaparc.H │   ├── lh.white.preaparc.K │   ├── rh.area │   ├── rh.curv │   ├── rh.defect_borders │   ├── rh.defect_chull │   ├── rh.defect_labels │   ├── rh.inflated │   ├── rh.inflated.H │   ├── rh.inflated.K │   ├── rh.inflated.nofix │   ├── rh.orig │   ├── rh.orig.nofix │   ├── rh.qsphere.nofix │   ├── rh.smoothwm │   ├── rh.smoothwm.BE.crv │   ├── rh.smoothwm.C.crv │   ├── rh.smoothwm.FI.crv │   ├── rh.smoothwm.H.crv │   ├── rh.smoothwm.K1.crv │   ├── rh.smoothwm.K2.crv │   ├── rh.smoothwm.K.crv │   ├── rh.smoothwm.nofix │   ├── rh.smoothwm.S.crv │   ├── rh.sulc │   ├── rh.white.H -> rh.white.preaparc.H │   ├── rh.white.K -> rh.white.preaparc.K │   ├── rh.white.preaparc │   ├── rh.white.preaparc.H │   └── rh.white.preaparc.K ├── tmp ├── touch │   ├── asegmerge.touch │   ├── ca_label.touch │   ├── ca_normalize.touch │   ├── ca_register.touch │   ├── conform.touch │   ├── em_register.touch │   ├── fill.touch │   ├── inorm1.touch │   ├── inorm2.touch │   ├── lh.curvstats.touch │   ├── lh.final_surfaces.touch │   ├── lh.inflate1.touch │   ├── lh.inflate2.touch │   ├── lh.inflate.H.K.touch │   ├── lh.qsphere.touch │   ├── lh.smoothwm1.touch │   ├── lh.smoothwm2.touch │   ├── lh.tessellate.touch │   ├── lh.topofix.touch │   ├── lh.white.H.K.touch │   ├── lh.white_surface.touch │   ├── nu.touch │   ├── rh.curvstats.touch │   ├── rh.final_surfaces.touch │   ├── rh.inflate1.touch │   ├── rh.inflate2.touch │   ├── rh.inflate.H.K.touch │   ├── rh.qsphere.touch │   ├── rh.smoothwm1.touch │   ├── rh.smoothwm2.touch │   ├── rh.tessellate.touch │   ├── rh.topofix.touch │   ├── rh.white.H.K.touch │   ├── rh.white_surface.touch │   ├── rusage.mri_ca_register.dat │   ├── rusage.mri_em_register.dat │   ├── rusage.mri_em_register.skull.dat │   ├── rusage.mris_fix_topology.lh.dat │   ├── rusage.mris_fix_topology.rh.dat │   ├── rusage.mris_inflate.lh.dat │   ├── rusage.mris_inflate.rh.dat │   ├── rusage.mri_watershed.dat │   ├── skull.lta.touch │   ├── skull_strip.touch │   ├── talairach.touch │   └── wmsegment.touch └── trash ``` ```tree freesurfer_subjects/ └── arno ├── label ├── mri │   ├── mri_nu_correct.mni.log │   ├── orig │   │   └── 001.mgz │   ├── orig.mgz │   ├── rawavg.mgz │   ├── tmp.mri_nu_correct.mni.31494 │   │   ├── 0 │   │   │   ├── nu0.mnc │   │   │   ├── nu1_corr.mnc │   │   │   ├── nu1_est.hist │   │   │   ├── nu1_est.mnc │   │   │   ├── nu1_est.mnc.temp │   │   │   ├── nu1_est.sharp │   │   │   ├── nu1_log.mnc │   │   │   ├── nu1_mask.mnc │   │   │   ├── nu1_residue.mnc │   │   │   └── nu1_temp.mnc │   │   └── nu0.mnc │   └── transforms │   └── bak ├── scripts │   ├── build-stamp.txt │   ├── IsRunning.lh+rh │   ├── lastcall.build-stamp.txt │   ├── patchdir.txt │   ├── recon-all.cmd │   ├── recon-all.env │   ├── recon-all.local-copy │   ├── recon-all.log │   └── recon-all-status.log ├── stats ├── surf ├── tmp ├── touch │   └── conform.touch └── trash ```

I'm currently running a workflow of just this Node https://github.com/shnizzedy/mindboggle/blob/36ea945cfa4c1998f3a88b58f296c25be91713d5/mindboggle/mindboggle123#L179-L183 in a Singularity shell.

I'm also trying Docker with --plugin MultiProc --plugin_args "dict(n_procs=4,memory_gb=15)" --fs_openmp 4 --ants_num_threads 4 --mb_num_threads 4 and Singularity without since Nipype seems to be generating the shell comands consistently between Docker and Singularity.

Docker
recon-all -all -i /home/jovyan/work/example_mri_data/T1.nii.gz -subjid arno -sd /home/jovyan/work/mindboggle123_output/freesurfer_subjects

Node: recon-all (freesurfer)

Hierarchy : Mindboggle123.recon-all Exec ID : recon-all

Original Inputs

  • FLAIR_file : <undefined>
  • T1_files : ['/home/jovyan/work/example_mri_data/T1.nii.gz']
  • T2_file : <undefined>
  • args : <undefined>
  • big_ventricles : <undefined>
  • brainstem : <undefined>
  • directive : all
  • environ : {}
  • expert : <undefined>
  • flags : <undefined>
  • hemi : <undefined>
  • hippocampal_subfields_T1 : <undefined>
  • hippocampal_subfields_T2 : <undefined>
  • hires : <undefined>
  • mprage : <undefined>
  • mri_aparc2aseg : <undefined>
  • mri_ca_label : <undefined>
  • mri_ca_normalize : <undefined>
  • mri_ca_register : <undefined>
  • mri_edit_wm_with_aseg : <undefined>
  • mri_em_register : <undefined>
  • mri_fill : <undefined>
  • mri_mask : <undefined>
  • mri_normalize : <undefined>
  • mri_pretess : <undefined>
  • mri_remove_neck : <undefined>
  • mri_segment : <undefined>
  • mri_segstats : <undefined>
  • mri_tessellate : <undefined>
  • mri_watershed : <undefined>
  • mris_anatomical_stats : <undefined>
  • mris_ca_label : <undefined>
  • mris_fix_topology : <undefined>
  • mris_inflate : <undefined>
  • mris_make_surfaces : <undefined>
  • mris_register : <undefined>
  • mris_smooth : <undefined>
  • mris_sphere : <undefined>
  • mris_surf2vol : <undefined>
  • mrisp_paint : <undefined>
  • openmp : <undefined>
  • parallel : <undefined>
  • subject_id : arno
  • subjects_dir : /home/jovyan/work/mindboggle123_output/freesurfer_subjects
  • talairach : <undefined>
  • use_FLAIR : <undefined>
  • use_T2 : <undefined>
  • xopts : <undefined>
Singularity
recon-all -all -i /home/jovyan/work/example_mri_data/T1.nii.gz -openmp 4 -subjid arno -sd /home/jovyan/work/mindboggle123_singularity_output_cleanenv/freesurfer_subjects

Node: recon-all (freesurfer)

Hierarchy : Mindboggle123.recon-all Exec ID : recon-all

Original Inputs

  • FLAIR_file : <undefined>
  • T1_files : ['/home/jovyan/work/example_mri_data/T1.nii.gz']
  • T2_file : <undefined>
  • args : <undefined>
  • big_ventricles : <undefined>
  • brainstem : <undefined>
  • directive : all
  • environ : {}
  • expert : <undefined>
  • flags : <undefined>
  • hemi : <undefined>
  • hippocampal_subfields_T1 : <undefined>
  • hippocampal_subfields_T2 : <undefined>
  • hires : <undefined>
  • mprage : <undefined>
  • mri_aparc2aseg : <undefined>
  • mri_ca_label : <undefined>
  • mri_ca_normalize : <undefined>
  • mri_ca_register : <undefined>
  • mri_edit_wm_with_aseg : <undefined>
  • mri_em_register : <undefined>
  • mri_fill : <undefined>
  • mri_mask : <undefined>
  • mri_normalize : <undefined>
  • mri_pretess : <undefined>
  • mri_remove_neck : <undefined>
  • mri_segment : <undefined>
  • mri_segstats : <undefined>
  • mri_tessellate : <undefined>
  • mri_watershed : <undefined>
  • mris_anatomical_stats : <undefined>
  • mris_ca_label : <undefined>
  • mris_fix_topology : <undefined>
  • mris_inflate : <undefined>
  • mris_make_surfaces : <undefined>
  • mris_register : <undefined>
  • mris_smooth : <undefined>
  • mris_sphere : <undefined>
  • mris_surf2vol : <undefined>
  • mrisp_paint : <undefined>
  • openmp : 4
  • parallel : <undefined>
  • subject_id : arno
  • subjects_dir : /home/jovyan/work/mindboggle123_singularity_output_cleanenv/freesurfer_subjects
  • talairach : <undefined>
  • use_FLAIR : <undefined>
  • use_T2 : <undefined>
  • xopts : <undefined>
shnizzedy commented 3 years ago

I think the problem is with threading / these flags: --plugin MultiProc --plugin_args "dict(n_procs=4,memory_gb=15)" --fs_openmp 4 --ants_num_threads 4 --mb_num_threads 4

Docker with `--plugin MultiProc --plugin_args "dict(n_procs=4,memory_gb=15)" --fs_openmp 4 --ants_num_threads 4 --mb_num_threads 4` Singularity without `--plugin MultiProc --plugin_args "dict(n_procs=4,memory_gb=15)" --fs_openmp 4 --ants_num_threads 4 --mb_num_threads 4`
```tree freesurfer_subjects/ └── arno ├── label ├── mri │   ├── orig │   │   └── 001.mgz │   ├── orig.mgz │   ├── rawavg.mgz │   └── transforms │   └── bak ├── scripts │   ├── build-stamp.txt │   ├── IsRunning.lh+rh │   ├── lastcall.build-stamp.txt │   ├── patchdir.txt │   ├── recon-all.cmd │   ├── recon-all.env │   ├── recon-all.local-copy │   ├── recon-all.log │   └── recon-all-status.log ├── stats ├── surf ├── tmp ├── touch └── trash ``` ```tree freesurfer_subjects/ └── arno ├── label │   ├── lh.cortex.label │   └── rh.cortex.label ├── mri │   ├── aseg.auto.mgz │   ├── aseg.auto_noCCseg.label_intensities.txt │   ├── aseg.auto_noCCseg.mgz │   ├── aseg.presurf.mgz │   ├── brain.finalsurfs.mgz │   ├── brainmask.auto.mgz │   ├── brainmask.mgz │   ├── brain.mgz │   ├── ctrl_pts.mgz │   ├── filled.mgz │   ├── mri_nu_correct.mni.log │   ├── mri_nu_correct.mni.log.bak │   ├── norm.mgz │   ├── nu.mgz │   ├── orig │   │   └── 001.mgz │   ├── orig.mgz │   ├── orig_nu.mgz │   ├── rawavg.mgz │   ├── segment.dat │   ├── T1.mgz │   ├── talairach.label_intensities.txt │   ├── talairach.log │   ├── talairach_with_skull.log │   ├── transforms │   │   ├── bak │   │   ├── cc_up.lta │   │   ├── talairach.auto.xfm │   │   ├── talairach.auto.xfm.lta │   │   ├── talairach_avi.log │   │   ├── talairach_avi_QA.log │   │   ├── talairach.lta │   │   ├── talairach.m3z │   │   ├── talairach_with_skull.lta │   │   ├── talairach.xfm │   │   └── talsrcimg_to_711-2C_as_mni_average_305_t4_vox2vox.txt │   ├── wm.asegedit.mgz │   ├── wm.mgz │   └── wm.seg.mgz ├── scripts │   ├── build-stamp.txt │   ├── IsRunning.lh+rh │   ├── lastcall.build-stamp.txt │   ├── patchdir.txt │   ├── ponscc.cut.log │   ├── recon-all.cmd │   ├── recon-all.env │   ├── recon-all.local-copy │   ├── recon-all.log │   └── recon-all-status.log ├── stats │   ├── lh.curv.stats │   └── rh.curv.stats ├── surf │   ├── lh.area │   ├── lh.curv │   ├── lh.defect_borders │   ├── lh.defect_chull │   ├── lh.defect_labels │   ├── lh.inflated │   ├── lh.inflated.H │   ├── lh.inflated.K │   ├── lh.inflated.nofix │   ├── lh.orig │   ├── lh.orig.nofix │   ├── lh.qsphere.nofix │   ├── lh.smoothwm │   ├── lh.smoothwm.BE.crv │   ├── lh.smoothwm.C.crv │   ├── lh.smoothwm.FI.crv │   ├── lh.smoothwm.H.crv │   ├── lh.smoothwm.K1.crv │   ├── lh.smoothwm.K2.crv │   ├── lh.smoothwm.K.crv │   ├── lh.smoothwm.nofix │   ├── lh.smoothwm.S.crv │   ├── lh.sulc │   ├── lh.white.H -> lh.white.preaparc.H │   ├── lh.white.K -> lh.white.preaparc.K │   ├── lh.white.preaparc │   ├── lh.white.preaparc.H │   ├── lh.white.preaparc.K │   ├── rh.area │   ├── rh.curv │   ├── rh.defect_borders │   ├── rh.defect_chull │   ├── rh.defect_labels │   ├── rh.inflated │   ├── rh.inflated.H │   ├── rh.inflated.K │   ├── rh.inflated.nofix │   ├── rh.orig │   ├── rh.orig.nofix │   ├── rh.qsphere.nofix │   ├── rh.smoothwm │   ├── rh.smoothwm.BE.crv │   ├── rh.smoothwm.C.crv │   ├── rh.smoothwm.FI.crv │   ├── rh.smoothwm.H.crv │   ├── rh.smoothwm.K1.crv │   ├── rh.smoothwm.K2.crv │   ├── rh.smoothwm.K.crv │   ├── rh.smoothwm.nofix │   ├── rh.smoothwm.S.crv │   ├── rh.sulc │   ├── rh.white.H -> rh.white.preaparc.H │   ├── rh.white.K -> rh.white.preaparc.K │   ├── rh.white.preaparc │   ├── rh.white.preaparc.H │   └── rh.white.preaparc.K ├── tmp ├── touch │   ├── asegmerge.touch │   ├── ca_label.touch │   ├── ca_normalize.touch │   ├── ca_register.touch │   ├── conform.touch │   ├── em_register.touch │   ├── fill.touch │   ├── inorm1.touch │   ├── inorm2.touch │   ├── lh.curvstats.touch │   ├── lh.final_surfaces.touch │   ├── lh.inflate1.touch │   ├── lh.inflate2.touch │   ├── lh.inflate.H.K.touch │   ├── lh.qsphere.touch │   ├── lh.smoothwm1.touch │   ├── lh.smoothwm2.touch │   ├── lh.tessellate.touch │   ├── lh.topofix.touch │   ├── lh.white.H.K.touch │   ├── lh.white_surface.touch │   ├── nu.touch │   ├── rh.curvstats.touch │   ├── rh.final_surfaces.touch │   ├── rh.inflate1.touch │   ├── rh.inflate2.touch │   ├── rh.inflate.H.K.touch │   ├── rh.qsphere.touch │   ├── rh.smoothwm1.touch │   ├── rh.smoothwm2.touch │   ├── rh.tessellate.touch │   ├── rh.topofix.touch │   ├── rh.white.H.K.touch │   ├── rh.white_surface.touch │   ├── rusage.mri_ca_register.dat │   ├── rusage.mri_em_register.dat │   ├── rusage.mri_em_register.skull.dat │   ├── rusage.mris_fix_topology.lh.dat │   ├── rusage.mris_fix_topology.rh.dat │   ├── rusage.mris_inflate.lh.dat │   ├── rusage.mris_inflate.rh.dat │   ├── rusage.mri_watershed.dat │   ├── skull.lta.touch │   ├── skull_strip.touch │   ├── talairach.touch │   └── wmsegment.touch └── trash ```
shnizzedy commented 3 years ago

Without threading, Singularity completed without error! The run took ~30 hours.

I'm going to try to force FreeSurfer to not thread but allow ANTs to.