From shinhm91 at bu.edu Mon Sep 14 08:57:01 2020 From: shinhm91 at bu.edu (Hye Min Shin) Date: Mon, 14 Sep 2020 21:57:01 +0900 Subject: [MINC-users] Nu_correct error: mask volume and input volume different in size Message-ID: Hello, I was wondering if someone can help me understand the issue I am running into with nu_correct. During the nu_correct stage while preprocessing MRI images through a modified version of FreeSurfer and I ran into this error: Iteration 1 2020. 09. 08. (?) 22:45:28 KST nu_correct -clobber /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu0.mnc /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu1.mnc -tmpdir /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/0/ -iterations 1000 -distance 50 -mask /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/mask.mnc [shinhm91 at metamind-H270:/home/shinhm91/fastsurfer_analysis/005_S_0602/mri/] [2020-09-08 22:45:28] running: /usr/local/freesurfer/mni/bin/nu_estimate_np_and_em -parzen -log -sharpen 0.15 0.01 -iterations 1000 -stop 0.001 -shrink 4 -auto_mask -nonotify -b_spline 1.0e-7 -distance 50 -mask /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/mask.mnc -quiet -execute -clobber -nokeeptmp -tmpdir /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/0/ /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu0.mnc /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu1.imp Transforming slices:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Processing:.................................................................Done Number of iterations: 56 CV of field change: 0.000980823 Mask volume and input volume must be the same size. nu_evaluate: crashed while running evaluate_field (termination status=512) nu_correct: crashed while running nu_evaluate (termination status=512) ERROR: nu_correct Command exited with non-zero status 1 @#@FSTIME 2020:09:08:22:45:23 mri_nu_correct.mni N 13 e 24.51 S 1.99 U 22.21 P 98% M 158792 F 108 R 587187 W 0 c 1830 w 5685 I 35488 O 1185720 L 3.65 2.13 1.79 @#@FSLOADPOST 2020:09:08:22:45:48 mri_nu_correct.mni N 13 3.24 2.15 1.81 So I was able to find from MINC wikibooks page ( https://en.wikibooks.org/wiki/MINC/Tools/N3) about possibly fixing this issue with specified mask volume by running the code: mincmath -gt -const 0 mask.mnc new_mask.mnc but that still didn't solve the problem. I tried checking file sizes for mask.mnc and nu0.mnc and the funny thing is before running nu_correct both mask.mnc and nu0.mnc files are indeed same in size: 211M . <---- parent directory size 65M ./nu0.mnc 65M ./new_mask.mnc 65M ./mask.mnc 19M ./0 140K ./mask.mgz 20K ./nu1.imp but if you see the tmp file called 0 that is used to store files while running nu_correct, mask.mnc and nu0.mnc files are different in size: 8.5M . <---- ./0 temp directory for running nu_correct 1.1M ./nu1_temp.mnc 1.1M ./nu1_residue.mnc 1.1M ./nu1_log.mnc 1.1M ./nu1_est.mnc.temp 1.1M ./nu1_est.mnc 1.1M ./nu1_corr.mnc 1.1M ./nu0.mnc 544K ./nu1_mask.mnc 276K ./new_mask.mnc 276K ./mask.mnc 8.0K ./nu1_est.sharp 8.0K ./nu1_est.hist Does nu_correct re-process nu0.mnc and mask.mnc from original files? I just want to understand how I got different file sizes in tmp directory. Best, Julia Shin From claude at bic.mni.mcgill.ca Mon Sep 14 10:27:30 2020 From: claude at bic.mni.mcgill.ca (Claude LEPAGE) Date: Mon, 14 Sep 2020 10:27:30 -0400 Subject: [MINC-users] Nu_correct error: mask volume and input volume different in size In-Reply-To: Message-ID: <202009141427.08EERUZw004444@login2.bic.mni.mcgill.ca> Hi, By same size, we mean the dimensions of the volume, not the file size on disk. Same number of voxels in x, y, z directions. You can use the command mincinfo on the volume and the mask. % mincinfo t1_final.mnc file: t1_final.mnc image: signed__ float 0 to 70760.0625 image dimensions: zspace yspace xspace dimension name length step start -------------- ------ ---- ----- zspace 255 0.25 -26.75 yspace 430 0.25 -61.5 xspace 421 0.25 -52.5 The mask needs to be the same size with the same dimension order (here z, y, x). Use mincresample to resample the mask like the input volume. mincresample -clobber -like t1_image.mnc -nearest input_mask.mnc output_mask.mnc Note: -nearest is to have a binary mask 0,1. It would be interesting to know which version of N3 FreeSurfer is still using. Last I heard, it was an ancient version based on minc-1 format (uncompressed). But FreeSurfer does work without crashing at this stage, so maybe it's a problem introduced in your modified version. Claude > > Hello, > > I was wondering if someone can help me understand the issue I am running > into with nu_correct. > > During the nu_correct stage while preprocessing MRI images through a > modified version of FreeSurfer and I ran into this error: > > Iteration 1 2020. 09. 08. (?) 22:45:28 KST > nu_correct -clobber > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu0.mnc > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu1.mnc > -tmpdir > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/0/ > -iterations 1000 -distance 50 -mask > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/mask.mnc > [shinhm91 at metamind-H270:/home/shinhm91/fastsurfer_analysis/005_S_0602/mri/] > [2020-09-08 22:45:28] running: > /usr/local/freesurfer/mni/bin/nu_estimate_np_and_em -parzen -log -sharpen > 0.15 0.01 -iterations 1000 -stop 0.001 -shrink 4 -auto_mask -nonotify > -b_spline 1.0e-7 -distance 50 -mask > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/mask.mnc > -quiet -execute -clobber -nokeeptmp -tmpdir > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/0/ > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu0.mnc > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu1.imp > > Transforming > slices:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Processing:.................................................................Done > Number of iterations: 56 > CV of field change: 0.000980823 > Mask volume and input volume must be the same size. > nu_evaluate: crashed while running evaluate_field (termination status=512) > nu_correct: crashed while running nu_evaluate (termination status=512) > ERROR: nu_correct > Command exited with non-zero status 1 > @#@FSTIME 2020:09:08:22:45:23 mri_nu_correct.mni N 13 e 24.51 S 1.99 U > 22.21 P 98% M 158792 F 108 R 587187 W 0 c 1830 w 5685 I 35488 O 1185720 L > 3.65 2.13 1.79 > @#@FSLOADPOST 2020:09:08:22:45:48 mri_nu_correct.mni N 13 3.24 2.15 1.81 > > So I was able to find from MINC wikibooks page ( > https://en.wikibooks.org/wiki/MINC/Tools/N3) about possibly fixing this > issue with specified mask volume by running the code: mincmath -gt -const 0 > mask.mnc new_mask.mnc but that still didn't solve the problem. > > I tried checking file sizes for mask.mnc and nu0.mnc and the funny thing is > before running nu_correct both mask.mnc and nu0.mnc files are indeed same > in size: > > 211M . <---- parent directory size > 65M ./nu0.mnc > 65M ./new_mask.mnc > 65M ./mask.mnc > 19M ./0 > 140K ./mask.mgz > 20K ./nu1.imp > > but if you see the tmp file called 0 that is used to store files while > running nu_correct, mask.mnc and nu0.mnc files are different in size: > > 8.5M . <---- ./0 temp directory for running nu_correct > 1.1M ./nu1_temp.mnc > 1.1M ./nu1_residue.mnc > 1.1M ./nu1_log.mnc > 1.1M ./nu1_est.mnc.temp > 1.1M ./nu1_est.mnc > 1.1M ./nu1_corr.mnc > 1.1M ./nu0.mnc > 544K ./nu1_mask.mnc > 276K ./new_mask.mnc > 276K ./mask.mnc > 8.0K ./nu1_est.sharp > 8.0K ./nu1_est.hist > > Does nu_correct re-process nu0.mnc and mask.mnc from original files? I just > want to understand how I got different file sizes in tmp directory. > > Best, > Julia Shin > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > https://mailman.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From shinhm91 at bu.edu Mon Sep 14 11:21:58 2020 From: shinhm91 at bu.edu (Hye Min Shin) Date: Tue, 15 Sep 2020 00:21:58 +0900 Subject: [MINC-users] Nu_correct error: mask volume and input volume different in size In-Reply-To: <202009141427.08EERUZw004444@login2.bic.mni.mcgill.ca> References: <202009141427.08EERUZw004444@login2.bic.mni.mcgill.ca> Message-ID: Hi Claude, Thank you very much for your reply. Your suggestion to use mincresample worked perfectly and I was able to run the freesurfer script mri_nu_correct.mni successfully using the newly resampled mask. For your information, from the freesurfer log file it looks like freesurfer is using the following version of N3: Program nu_correct, built from: Package MNI N3, version 1.12.0, compiled by nicks at terrier (x86_64-unknown-linux-gnu) on 2015-06-19 at 01:25:34 Another interesting thing is that when I used mincinfo both on the volume and the mask, it seems like both were in the same size and dimension order: shinhm91 at metamind-H270:~$ mincinfo /media/shinhm91/braindata/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.19089/mask.mnc file: /media/shinhm91/braindata/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.19089/mask.mnc image: signed__ float 0 to 1 image dimensions: xspace yspace zspace dimension name length step start -------------- ------ ---- ----- xspace 256 1 -324.117 yspace 256 1 -670.137 zspace 256 1 165.341 shinhm91 at metamind-H270:~$ mincinfo /media/shinhm91/braindata/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.19089/nu0.mnc file: /media/shinhm91/braindata/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.19089/nu0.mnc image: signed__ float 0 to 255 image dimensions: xspace yspace zspace dimension name length step start -------------- ------ ---- ----- xspace 256 1 -324.117 yspace 256 1 -670.137 zspace 256 1 165.341 But I still used mincresample method as you mentioned anyway and I was able to get past the error. Best, Julia Shin On Mon, Sep 14, 2020 at 11:31 PM Claude LEPAGE wrote: > Hi, > > By same size, we mean the dimensions of the volume, not the file > size on disk. Same number of voxels in x, y, z directions. You can > use the command mincinfo on the volume and the mask. > > % mincinfo t1_final.mnc > > file: t1_final.mnc > image: signed__ float 0 to 70760.0625 > image dimensions: zspace yspace xspace > dimension name length step start > -------------- ------ ---- ----- > zspace 255 0.25 -26.75 > yspace 430 0.25 -61.5 > xspace 421 0.25 -52.5 > > The mask needs to be the same size with the same dimension order > (here z, y, x). > > Use mincresample to resample the mask like the input volume. > > mincresample -clobber -like t1_image.mnc -nearest input_mask.mnc > output_mask.mnc > > Note: -nearest is to have a binary mask 0,1. > > It would be interesting to know which version of N3 FreeSurfer is still > using. Last I heard, it was an ancient version based on minc-1 format > (uncompressed). But FreeSurfer does work without crashing at this stage, > so maybe it's a problem introduced in your modified version. > > Claude > > > > > > Hello, > > > > I was wondering if someone can help me understand the issue I am running > > into with nu_correct. > > > > During the nu_correct stage while preprocessing MRI images through a > > modified version of FreeSurfer and I ran into this error: > > > > Iteration 1 2020. 09. 08. (?) 22:45:28 KST > > nu_correct -clobber > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu0.mnc > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu1.mnc > > -tmpdir > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/0/ > > -iterations 1000 -distance 50 -mask > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/mask.mnc > > [shinhm91 at metamind-H270 > :/home/shinhm91/fastsurfer_analysis/005_S_0602/mri/] > > [2020-09-08 22:45:28] running: > > /usr/local/freesurfer/mni/bin/nu_estimate_np_and_em -parzen -log > -sharpen > > 0.15 0.01 -iterations 1000 -stop 0.001 -shrink 4 -auto_mask -nonotify > > -b_spline 1.0e-7 -distance 50 -mask > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/mask.mnc > > -quiet -execute -clobber -nokeeptmp -tmpdir > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/0/ > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu0.mnc > > > /home/shinhm91/fastsurfer_analysis/005_S_0602/mri/tmp.mri_nu_correct.mni.9950/nu1.imp > > > > Transforming > > > slices:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > > Processing:.................................................................Done > > Number of iterations: 56 > > CV of field change: 0.000980823 > > Mask volume and input volume must be the same size. > > nu_evaluate: crashed while running evaluate_field (termination > status=512) > > nu_correct: crashed while running nu_evaluate (termination status=512) > > ERROR: nu_correct > > Command exited with non-zero status 1 > > @#@FSTIME 2020:09:08:22:45:23 mri_nu_correct.mni N 13 e 24.51 S 1.99 U > > 22.21 P 98% M 158792 F 108 R 587187 W 0 c 1830 w 5685 I 35488 O 1185720 L > > 3.65 2.13 1.79 > > @#@FSLOADPOST 2020:09:08:22:45:48 mri_nu_correct.mni N 13 3.24 2.15 1.81 > > > > So I was able to find from MINC wikibooks page ( > > https://en.wikibooks.org/wiki/MINC/Tools/N3) about possibly fixing this > > issue with specified mask volume by running the code: mincmath -gt > -const 0 > > mask.mnc new_mask.mnc but that still didn't solve the problem. > > > > I tried checking file sizes for mask.mnc and nu0.mnc and the funny thing > is > > before running nu_correct both mask.mnc and nu0.mnc files are indeed same > > in size: > > > > 211M . <---- parent directory size > > 65M ./nu0.mnc > > 65M ./new_mask.mnc > > 65M ./mask.mnc > > 19M ./0 > > 140K ./mask.mgz > > 20K ./nu1.imp > > > > but if you see the tmp file called 0 that is used to store files while > > running nu_correct, mask.mnc and nu0.mnc files are different in size: > > > > 8.5M . <---- ./0 temp directory for running nu_correct > > 1.1M ./nu1_temp.mnc > > 1.1M ./nu1_residue.mnc > > 1.1M ./nu1_log.mnc > > 1.1M ./nu1_est.mnc.temp > > 1.1M ./nu1_est.mnc > > 1.1M ./nu1_corr.mnc > > 1.1M ./nu0.mnc > > 544K ./nu1_mask.mnc > > 276K ./new_mask.mnc > > 276K ./mask.mnc > > 8.0K ./nu1_est.sharp > > 8.0K ./nu1_est.hist > > > > Does nu_correct re-process nu0.mnc and mask.mnc from original files? I > just > > want to understand how I got different file sizes in tmp directory. > > > > Best, > > Julia Shin > > _______________________________________________ > > MINC-users at bic.mni.mcgill.ca > > https://mailman.bic.mni.mcgill.ca/mailman/listinfo/minc-users > > > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > https://mailman.bic.mni.mcgill.ca/mailman/listinfo/minc-users >