title: How to fix error in fslvbm_2_template where no template_4D_GM file is created
body: <p>I am running a VBM analysis in FSL. I have searched on the JISC Mail archives for solutions to this error but have had no luck. I have a lot of available space on my laptop, so it is not a space issue. I have also had this problem across multiple Mac systems. Any help will be greatly appreciated, I have been struggling with this for days.</p>
  
  <p>When I run the code "fslvbm_2_template -n" I am expecting to create a file named template_4D_GM but get this error code in the output:</p>
  
  <pre><code>Running segmentation: ID=64663
  Running initial registration: ID=64926
  
  Image Exception : #63 :: No image files match: 1_002_s_####_struc_GM_to_T
  libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: No image files match: 1_002_s_####_struc_GM_to_T
  ./fslvbm2c: line 13: 68739 Abort trap: 6 
  $FSLDIR/bin/fslmerge -t template_4D_GM $mergelist
  
  Image Exception : #63 :: No image files match: template_4D_GM
  libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: No image files match: template_4D_GM
  ./fslvbm2c: line 14: 68740 Abort trap: 6
  $FSLDIR/bin/fslmaths template_4D_GM -Tmean template_GM
  
  Image Exception : #63 :: No image files match: template_GM
  No image files match: template_GM
  /usr/local/fsl/bin/fslswapdim: line 107: [: =: unary operator expected
  Image Exception : #63 :: No image files match: template_GM
  No image files match: template_GM
  /usr/local/fsl/bin/fslswapdim: line 115: [: -gt: unary operator expected
  
  Image Exception : #63 :: No image files match: template_GM
  No image files match: template_GM
  /usr/local/fsl/bin/fslswapdim: line 117: [: -gt: unary operator expected
  
  Image Exception : #63 :: No image files match: template_GM
  libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: No image files match: template_GM
  /usr/local/fsl/bin/fslswapdim: line 184: 68769 Abort trap: 6           $comm
  
  Image Exception : #63 :: No image files match: template_GM
  libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: No image files match: template_GM
  ./fslvbm2c: line 16: 68770 Abort trap: 6
  $FSLDIR/bin/fslmaths template_GM -add template_GM_flipped -div 2 template_GM_init
  
  Creating first-pass template: ID=
  Running registration to first-pass template: ID=The command you have requested cannot be found or is not executable
  /usr/local/fsl/bin/fsl_sub: line 514: you: command not found
  Creating second-pass template: ID=
  Study-specific template will be created, when complete, check results with:
  fslview struc/template_4D_GM
  and turn on the movie loop to check all subjects, then run:
  fslview  /usr/local/fsl/data/standard/tissuepriors/avg152T1_gray  struc/template_GM
  to check general alignment of mean GM template vs. original standard space template.
  </code></pre>
  
  <p>When running "fslvbm_2_template -n" I find that fslvbm2a and fslvbm2b will run without error but I hit the problem at fslvbm2c. When I run this specific piece of code from the fslvbm_2_template - FSLVBM template creation (<a href="http://ftp.nmr.mgh.harvard.edu/pub/dist/freesurfer/tutorial_packages/OSX/fsl_501/bin/fslvbm_2_template" rel="nofollow noreferrer">http://ftp.nmr.mgh.harvard.edu/pub/dist/freesurfer/tutorial_packages/OSX/fsl_501/bin/fslvbm_2_template</a>):</p>
  
  <pre><code>MacBook-Pro:struc name$ cat &lt;&lt;stage_tpl3 &gt; fslvbm2c
  #!/bin/sh
  
  &gt; if [ -f ../template_list ] ; then
  
  &gt;   template_list=\`cat ../template_list\`
  
  &gt;   template_list=\`\$FSLDIR/bin/remove_ext \$template_list\`
  
  &gt; else
  
  &gt;   template_list=\`echo *_struc.* | sed 's/_struc\./\./g'\`
  
  &gt;   template_list=\`\$FSLDIR/bin/remove_ext \$template_list | sort -u\`
  
  &gt;     echo "WARNING - study-specific template will be created from ALL input data - may not be group-size matched!!!"
  
  &gt; fi
  
  &gt; for g in \$template_list ; do
  
  &gt;     mergelist="\$mergelist \${g}_struc_GM_to_T"
  
  &gt; done
  
  &gt; \$FSLDIR/bin/fslmerge -t template_4D_GM \$mergelist
  
  &gt; \$FSLDIR/bin/fslmaths template_4D_GM -Tmean template_GM
  
  &gt; \$FSLDIR/bin/fslswapdim template_GM -x y z template_GM_flipped
  
  &gt; \$FSLDIR/bin/fslmaths template_GM -add template_GM_flipped -div 2 template_GM_init
  
  &gt; stage_tpl3
  
  MacBook-Pro:struc name$ chmod +x fslvbm2c
  
  MacBook-Pro:struc name$ fslvbm2c_id=`fsl_sub -j $fslvbm2b_id -T 15 -N 
  fslvbm2c ./fslvbm2c`
  
  MacBook-Pro:struc name$ echo Creating first-pass template: `ID=$fslvbm2c_id`
  Creating first-pass template: ID=The command you have requested cannot be found or is not executable
  </code></pre>