BIC-MNI / mni_autoreg

MINC mni_autoreg
Other
8 stars 9 forks source link

minctracc HEAD: Cannot calculate the COG or COV of volume 1. #15

Open gdevenyi opened 7 years ago

gdevenyi commented 7 years ago

I have some volumes I'm trying to register in pydpiper, minctracc can't seem to find their COG/COV, despite everything looking fine with register...

> minctracc -clobber -w_translations 0.4 0.4 0.4 -w_rotations 0.0174533 0.0174533 0.0174533 -w_scales 0.02 0.02 0.02 -w_shear 0.02 0.02 0.02 -step 9.0 9.0 9.0 -simplex 12.8 -use_simplex -tol 0.0001 /data/chamal/projects/gabriel/lizard-test/lizard_processed/CVuncF/tmp/CVuncF_fwhm9_blur.mnc /data/chamal/projects/gabriel/lizard-test/lizard_bootstrap_file/CC10Fe/tmp/CC10Fe_fwhm9_blur.mnc /data/chamal/projects/gabriel/lizard-test/lizard_processed/CVuncF/transforms/CVuncF_to_CC10Fe_lsq6_0.xfm -xcorr -lsq6 -est_center -est_translations -debug
===== Debugging information from minctracc =====
Data filename       = /data/chamal/projects/gabriel/lizard-test/lizard_processed/CVuncF/tmp/CVuncF_fwhm9_blur.mnc
Model filename      = /data/chamal/projects/gabriel/lizard-test/lizard_bootstrap_file/CC10Fe/tmp/CC10Fe_fwhm9_blur.mnc
Data mask filename  = 
Model mask filename = 
Input xform name    = 
Output filename     = /data/chamal/projects/gabriel/lizard-test/lizard_processed/CVuncF/transforms/CVuncF_to_CC10Fe_lsq6_0.xfm
Step size           = 9.000000 9.000000 9.000000
Sub-lattice dia     = 24.000000 24.000000 24.000000
Objective function  = cross correlation (threshold = 0.000000 0.000000)
Transform linear    = TRUE
Transform inverted? = FALSE
Transform type      = 3
Transform matrix    =    1.0000    0.0000    0.0000    0.0000 
                         0.0000    1.0000    0.0000    0.0000 
                         0.0000    0.0000    1.0000    0.0000 
Transform center   =    0.000    0.000    0.000
Transform rotation   =    0.000    0.000    0.000 

Transform trans    =    0.000    0.000    0.000
Transform scale    =    1.000    1.000    1.000

Source volume size: 110  by 110  by 160 
Source voxel size =   -0.100   -0.100    0.100
Source min/max real range =   22.472  786.514
Source min/max voxel=   22.472  786.514

Target volume size: 110  by 110  by 160 
Target voxel =   -0.100   -0.100    0.100
Target min/max real range=   22.220  810.026
Target min/max voxel =   22.220  810.026

  using PAT to get initial parameters:
  will try to get: [center] [trans]
In set_up_lattice, xyzv[axes] = 2, 1, 0, -1
Error in minctracc in file /opt/quarantine/minc-toolkit/git/src/minc-toolkit-v2/mni_autoreg/minctracc/Numerical/init_params.c, line 593
Cannot calculate the COG or COV of volume 1.
gdevenyi commented 5 years ago

Following up, I have some new data that also throws the same errors in minctracc:

minctracc -clobber -debug -xcorr -est_center -est_translations -lsq6 -step 3.571425 3.571425 3.571425 -simplex 5.07936 -tol 0.0001 -w_shear 0.02 0.02 0.02 -w_scales 0.02 0.02 0.02 -w_rotations 0.0174533 0.0174533 0.0174533 -w_translations 0.4 0.4 0.4 -model_mask cropped_embryo_mia_30012019_reg_target_resampled/E18_mask_39micron_resampled.mnc cropped_embryo_mia_30012019_processed/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre/tmp/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre_fwhm3.571425_blur.mnc cropped_embryo_mia_30012019_reg_target_resampled/tmp/E18_39micron_resampled_fwhm3.571425_blur.mnc cropped_embryo_mia_30012019_processed/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre/tmp/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre_mt_to_E18_39micron_resampled_lsq6_0.xfm
Before parsing
===== Debugging information from minctracc =====
Data filename       = cropped_embryo_mia_30012019_processed/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre/tmp/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre_fwhm3.571425_blur.mnc
Model filename      = cropped_embryo_mia_30012019_reg_target_resampled/tmp/E18_39micron_resampled_fwhm3.571425_blur.mnc
Data mask filename  = 
Model mask filename = cropped_embryo_mia_30012019_reg_target_resampled/E18_mask_39micron_resampled.mnc
Input xform name    = 
Output filename     = cropped_embryo_mia_30012019_processed/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre/tmp/img_21nov18.14.sept2014_dist_corr_preproc_I_lsq6_recrop_centre_mt_to_E18_39micron_resampled_lsq6_0.xfm
Step size           = 3.571425 3.571425 3.571425
Sub-lattice dia     = 24.000000 24.000000 24.000000
Objective function  = cross correlation (threshold = 0.000000 0.000000)
Transform linear    = TRUE
Transform inverted? = FALSE
Transform type      = 3
Transform matrix    =    1.0000    0.0000    0.0000    0.0000 
                         0.0000    1.0000    0.0000    0.0000 
                         0.0000    0.0000    1.0000    0.0000 
Transform center   =    0.000    0.000    0.000
Transform rotation   =    0.000    0.000    0.000 

Transform trans    =    0.000    0.000    0.000
Transform scale    =    1.000    1.000    1.000

Reading Volume: ...............................................................Source volume size: 179  by 305  by 219 
Source voxel size =    0.040    0.040    0.040
Source min/max real range =   69.217 15639.158
Source min/max voxel=   69.217 15639.158

Target volume size: 193  by 317  by 221 
Target voxel =    0.040    0.040    0.040
Target min/max real range=   24.660 1877.354
Target min/max voxel =   24.660 1877.354

Error in minctracc in file /opt/quarantine/minc-toolkit/1.9.16/src/minc-toolkit-v2/mni_autoreg/minctracc/Numerical/init_params.c, line 602
Cannot calculate the COG or COV of volume 2.

  using PAT to get initial parameters:
  will try to get: [center] [trans]
In set_up_lattice, xyzv[axes] = 2, 1, 0, -1
COG of v1: 0.022438 -0.347027 -0.581902
In set_up_lattice, xyzv[axes] = 2, 1, 0, -1
In set_up_lattice, xyzv[axes] = 2, 1, 0, -1
in vol to cov
start =    15.97     2.50     2.09 
count =        2        4        2 
step  =     3.57     3.57     3.57 
direct=     1.00     0.00     0.00 
direct=     0.00     1.00     0.00 
direct=     0.00     0.00     1.00 
In set_up_lattice, xyzv[axes] = 2, 1, 0, -1
vfonov commented 5 years ago

did you check if there are any NaN voxels?

gdevenyi commented 5 years ago

I have not, will do so thanks!

gdevenyi commented 5 years ago

Non NAN voxels.

The issue appears to be the COG/COM estimate is failing due to masking, if I remove the model_mask from the call, the command succeeds:

A visualization of why there might be a corner case: image

vfonov commented 5 years ago

does mask have voxels that are only 0 and 1 ?

gdevenyi commented 5 years ago

Currently the mask has other values (see https://github.com/Mouse-Imaging-Centre/pydpiper/issues/405) in the pipeline, manually fixing the mask to only 0/1 doesn't change the result, same crash.

vfonov commented 5 years ago

so, you have a minc file sampled at 0.040 mm and your lattice size is 24mm . Maybe that's the problem?

gdevenyi commented 5 years ago

Maybe, it does seem to work without the mask. This call is automatically generated from pydpiper and I'm not quite clear on the semantics.

Paging @bcdarwin, pydpiper is driving this bug, can you comment?

vfonov commented 5 years ago

also this shows something:

in vol to cov
start =    15.97     2.50     2.09 
count =        2        4        2 
step  =     3.57     3.57     3.57 
direct=     1.00     0.00     0.00 
direct=     0.00     1.00     0.00 
direct=     0.00     0.00     1.00 

The whole volume will be sampled 2 times in x direction ( count variable ) - if it happen to miss the mask , the result will be undefined.

bcdarwin commented 5 years ago

When you say Pydpiper is driving this, do you mean that it's the mask issue? In your first example, there doesn't seem to be a mask.

I'm working on something that needs a principal axis transformation with pre-existing masks at the moment so perhaps I'll encounter the same issue ...

gdevenyi commented 5 years ago

@bcdarwin I think it may be the way that the resolution spacing is chosen for the initialization, the mask in this case exposed the problem, though in the other case it was probably the resolution on its own.