Skip to content
Snippets Groups Projects
Commit 3de17f55 authored by tischi's avatar tischi
Browse files

Update registration files

parent b60a3891
No related branches found
No related tags found
No related merge requests found
Showing
with 1021 additions and 0 deletions
......@@ -6,3 +6,4 @@ data/dev-*
*.tif
*.swp
software
*.zip
# General notes
We are using a SmoothingImagePyramid thus there is not downsampling.
As a consequence the NumberOfSpatialSamples does not have to be adapted to the settings for computing the SmoothingImagePyramid. In fact, I thus changed the name of the corresponding setting in the UI to GaussianSmoothingSigma
It is important to use a good mask in order to restrict the computation to relevant image regions.
In the belly region there are not many nuclei, thus we only rely on the muscles. Thus it could make sense to give them more weight during registration.
I do not have a good feeling for which NumberOfSpatialSamples makes sense. Maybe makes more sense to think in terms of fraction of pixels within mask?
In our mask there are around 40.000.000 pixels.
Maybe less NumberOfSpatialSamples but rather high NumberOfIterations is a good strategy in order to explore more possibilities?
The neuropil is not present in one side of the belly region, thus putting to much weight on it during the registration might lead to bad alignments in this region. However, maybe, once the overall shape is well matched one can increase the weight during fine adjustments done at more fine grained BSplines.
Changing the smoothing ( = ImagePyramidSchedule ) during the registration can be confusing, because the quality metric values will change as well. However, the feeling is that in order to get high accuracy at fine grained BSplines one might need to smooth less?!
Also changing the channel weights will change the overall metric value, the ones of the individual channels stay the same though.
# Rotation pre-align
We use the rotation prealign as an inital transformation for the following ones.
# Similarity Experiment
All 3 channels were used, with muscles higher weight.
## Settings
(NumberOfSpatialSamples 10000)
(ImagePyramidSchedule 15 15 15) // smoothing sigma
(Metric0Weight 1.0 )
(Metric1Weight 3.0 )
(Metric2Weight 1.0 )
### Convergence
Interestingly after some stagnation between 999 and 1999 it really got much better at 2999, and then at the very end it again improved a lot.
0 -0.176163 -0.086445 -0.017606 -0.036900
999 -0.215712 -0.104530 -0.022902 -0.042477
1999 -0.228947 -0.116048 -0.022588 -0.045135
2999 -0.451720 -0.253755 -0.037443 -0.085637 (! strong improvement )
3999 -0.484159 -0.270394 -0.039010 -0.096735
4998 -0.489826 -0.284614 -0.036759 -0.094934
5999 -0.508868 -0.287047 -0.040110 -0.101491
6999 -0.491788 -0.272042 -0.036517 -0.110193
7999 -0.603236 -0.321716 -0.051854 -0.125957
8999 -0.991052 -0.432808 -0.126678 -0.178210 (! strong improvement )
9990 -0.987789 -0.411863 -0.131246 -0.182189
... I also ran again longer but after 10000 iterations there were no more improvements.
This makes sense because visually the result at 10000 looked super good for only a similarity transform, i.e. I could not see how to improve this.
## Conclusions
The results in the end looked really very good!
It seems to sometimes need that many (over even more) iterations to find a good registration.
It also seems that a strong smoothing is a good strategy (at least for finding an initial transformation), because, I think, it increases the basin of attraction, i.e. gradients are easier to find, especially given our binary input data.
# Affine
Maybe this can be skipped as there is no scientific reason why one sample should be shrunk in one specific direction more than in an other orthogonal direction ?!
I skipped it.
# BSpline 100
(Transform "BSplineTransform")
(MaximumNumberOfIterations 10000)
(ImagePyramidSchedule 15 15 15)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 100 100 100 )
(Metric0Weight 1.0 )
(Metric1Weight 3.0 )
(Metric2Weight 1.0 )
## Convergence
0 -0.970031 -0.385899 -0.131624 -0.189259
999 -1.743090 -0.786659 -0.237570 -0.243720 (!)
1999 -1.731396 -0.798075 -0.234096 -0.231031
2999 -1.753035 -0.796310 -0.239703 -0.237615
3999 -1.764563 -0.810492 -0.236706 -0.243955
...
9999 -1.758065 -0.814303 -0.234547 -0.240120
Looked super good.
# BSpline 40
(Transform "BSplineTransform")
(MaximumNumberOfIterations 1000)
(ImagePyramidSchedule 15 15 15)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 40 40 40 )
(Registration "MultiMetricMultiResolutionRegistration" )
(Metric0Weight 1.0 )
(Metric1Weight 3.0 )
(Metric2Weight 3.0 ) (! increased => sum weight increases)
## Convergence
0 -2.260248 -0.802621 -0.233172 -0.252703
999 -2.826055 -0.881758 -0.315233 -0.332866
Visual inspection looked good.
# BSpline 10
(Transform "BSplineTransform")
(MaximumNumberOfIterations 20000)
(ImagePyramidSchedule 2 2 2)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 10 10 10 )
(Registration "MultiMetricMultiResolutionRegistration" )
(Metric0Weight 1.0 )
(Metric1Weight 3.0 )
(Metric2Weight 3.0 )
## Convergence
0 -0.990674 -0.320771 -0.116196 -0.107105
999 -1.408272 -0.382236 -0.183522 -0.158490
1999 -1.503421 -0.378669 -0.201400 -0.173518
2999 -1.590716 -0.397182 -0.222692 -0.175153
3999 -1.526799 -0.377565 -0.214996 -0.168082
4999 -1.608387 -0.374712 -0.227718 -0.183507
5999 -1.633175 -0.389392 -0.232624 -0.181970
6999 -1.625030 -0.387114 -0.238305 -0.174333
7999 -1.642454 -0.379603 -0.244494 -0.176457
19999 -1.709767 -0.395723 -0.258848 -0.179167
Looks visually ok...but somehow I feel we need better information for better matching...
// Copy files from ProSPr to the EM working directory
// Mirror in the x axis (because the SP8 does it)
// Add dimension information
// Threshold them (Not the reference)
// Manage names
// Hernando MV. Sep2019
setBatchMode(true);
// directory of the curated MEDs
meds_dir = "/g/arendt/PrImR/ProSPr6/4SPM_Binarization/CuratedMEDs_Good/";
// ProSPr reference
ref_file = "/g/arendt/PrImR/ProSPr6/ProSPr6_Ref.tif";
// segmented data
trackem_dir = "/g/arendt/PrImR/ProSPr6/TrackEM/";
// output directory
outdir = "/g/arendt/EM_6dpf_segmentation/platy-browser-data/data/rawdata/prospr/";
// read dictionary
dic_file = "/g/arendt/EM_6dpf_segmentation/GenerationOfVirtualCells/ProSPr_VirtualCells/helper_files/OlegGenesDiccionary.txt";
filestring=File.openAsString(dic_file);
rows=split(filestring, "\n");
badname=newArray(rows.length);
goodname=newArray(rows.length);
for(i=0; i<rows.length; i++){
columns=split(rows[i],",");
badname[i]=columns[0];
goodname[i]=columns[1];
}
// get a list of the med files
meds_files = getFileList(meds_dir);
filenames = newArray();
for (i=0;i<meds_files.length;i++){
subfiles = getFileList(meds_dir+meds_files[i]);
for (j=0;j<subfiles.length;j++){
if (endsWith(subfiles[j],"_MEDs.tif")){
pieces = split(subfiles[j],"_");
// avoid inserting Pty2
if (pieces[0] != "Pty2"){
filenames = Array.concat(filenames,meds_dir+meds_files[i]+"/"+subfiles[j]);
}
}
}
}
// add the segmented data
trackem_files = getFileList(trackem_dir);
for (i=0;i<trackem_files.length;i++){
subfiles = getFileList(trackem_dir+trackem_files[i]);
for (j=0;j<subfiles.length;j++){
if (endsWith(subfiles[j],"_MEDs.tif")){
pieces = split(subfiles[j],"_");
// avoid inserting MB
if (pieces[0] != "MB"){
filenames = Array.concat(filenames,trackem_dir+trackem_files[i]+"/"+subfiles[j]);
}
}
}
}
for (i = 0; i < filenames.length; i++) {
// open
open(filenames[i]);
f_name = getTitle();
print(f_name);
// flip
run("Flip Horizontally", "stack");
// change properties
run("Properties...", "channels=1 slices=251 frames=1 unit=micrometers pixel_width=0.55 pixel_height=0.55 voxel_depth=0.55");
// threshold
setThreshold(1, 255);
setOption("BlackBackground", false);
run("Convert to Mask", "stack");
// save
// parse title
pieces = split(f_name, "_");
// find index of name
idx = getIndex(pieces[0], badname);
print(idx);
// get correspondent name
if(idx<9000){
genename = goodname[idx];
print(genename);
new_name = pieces[0] + "-" + genename + "--prosprspaceMEDs.tif";
}
else{
new_name = pieces[0] + "--prosprspaceMEDs.tif";
}
// correct Hox5
if(pieces[0]=="Hox5"){
new_name = "Hox4--prosprspaceMEDs.tif";
}
saveAs("Tiff", outdir + new_name);
close(new_name);
}
// copy the reference
open(ref_file);
print(getTitle());
// flip
run("Flip Horizontally", "stack");
// change properties
run("Properties...", "channels=1 slices=251 frames=1 unit=micrometers pixel_width=0.55 pixel_height=0.55 voxel_depth=0.55");
// save
new_name = "ProSPr6-Ref--prosprspaceMEDs.tif";
saveAs("Tiff", outdir + new_name);
close(new_name);
run("Close All");
print("DONE");
run("Quit");
function getIndex(word, array){
for (i = 0; i < array.length; i++) {
if (word == array[i]) {
return(i);
}
}
return(10000); // could not figure out how to make NaN work...
}
#!/bin/bash
#SBATCH -o "/g/arendt/EM_6dpf_segmentation/platy-browser-data/registration/transfer_ProSPr_data/copandmir.out"
#SBATCH -e "/g/arendt/EM_6dpf_segmentation/platy-browser-data/registration/transfer_ProSPr_data/copandmir.err"
#SBATCH --mem 16000
#SBATCH -c 4
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -p htc
#SBATCH -t 400
echo "starting job"
touch "/g/arendt/EM_6dpf_segmentation/platy-browser-data/registration/transfer_ProSPr_data/copandmir.started"
START_TIME=$SECONDS
ulimit -c 0
hostname
head -1 /proc/meminfo
module load X11
module load Java
xvfb-run -a -e "/g/arendt/EM_6dpf_segmentation/platy-browser-data/registration/transfer_ProSPr_data/copandmir.err" /g/almf/software/Fiji.app/ImageJ-linux64 -batch "/g/arendt/EM_6dpf_segmentation/platy-browser-data/registration/transfer_ProSPr_data/ProSPr_copy_and_mirror.ijm"
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "job finished"
touch "/g/arendt/EM_6dpf_segmentation/platy-browser-data/registration/transfer_ProSPr_data/copandmir.finished"
\ No newline at end of file
(Transform "AffineTransform")
(NumberOfParameters 12)
(TransformParameters 0.977125 -0.000950 0.014158 0.009513 0.972096 0.031365 -0.008023 0.014535 1.022907 -0.000406 0.000225 -0.000546)
(InitialTransformParametersFileName "./TransformParameters.Similarity.txt")
(HowToCombineTransforms "Compose")
// Image specific
(FixedImageDimension 3)
(MovingImageDimension 3)
(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(Size 550 518 570)
(Index 0 0 0)
(Spacing 0.0005000000 0.0005000000 0.0005000000)
(Origin 0.0000000000 0.0000000000 0.0000000000)
(Direction 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000)
(UseDirectionCosines "false")
// AdvancedAffineTransform specific
(CenterOfRotationPoint 0.0803247287 0.1133132771 0.0590322401)
// ResampleInterpolator specific
(ResampleInterpolator "FinalLinearInterpolator")
// Resampler specific
(Resampler "DefaultResampler")
(DefaultPixelValue 0.000000)
(ResultImageFormat "mhd")
(ResultImagePixelType "unsigned char")
(CompressResultImage "false")
(Transform "EulerTransform")
(NumberOfParameters 6)
(TransformParameters 1.5 0.2 -3.15 -0.1 -0.05 -0.05)
(InitialTransformParametersFileName "NoInitialTransform")
(HowToCombineTransforms "Compose")
// Image specific
(FixedImageDimension 3)
(MovingImageDimension 3)
(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(Size 550 518 570)
(Index 0 0 0)
(Spacing 0.0005000000 0.0005000000 0.0005000000)
(Origin 0.0000000000 0.0000000000 0.0000000000)
(Direction 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000)
(UseDirectionCosines "false")
// EulerTransform specific
(CenterOfRotationPoint 0.1622715807 0.1473624433 0.1127662152)
(ComputeZYX "false")
// ResampleInterpolator specific
(ResampleInterpolator "FinalLinearInterpolator")
// Resampler specific
(Resampler "DefaultResampler")
(DefaultPixelValue 0.000000)
(ResultImageFormat "mhd")
(ResultImagePixelType "unsigned char")
(CompressResultImage "false")
(Transform "SimilarityTransform")
(NumberOfParameters 7)
(TransformParameters 0.144588 0.446733 0.010764 0.017836 0.015540 -0.007642 0.783912)
(InitialTransformParametersFileName "./TransformParameters.RotationPreAlign.0.txt")
(HowToCombineTransforms "Compose")
// Image specific
(FixedImageDimension 3)
(MovingImageDimension 3)
(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(Size 550 518 570)
(Index 0 0 0)
(Spacing 0.0005000000 0.0005000000 0.0005000000)
(Origin 0.0000000000 0.0000000000 0.0000000000)
(Direction 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000)
(UseDirectionCosines "false")
// SimilarityTransform specific
(CenterOfRotationPoint 0.0622715807 0.0973624433 0.0627662152)
// ResampleInterpolator specific
(ResampleInterpolator "FinalLinearInterpolator")
// Resampler specific
(Resampler "DefaultResampler")
(DefaultPixelValue 0.000000)
(ResultImageFormat "mhd")
(ResultImagePixelType "unsigned char")
(CompressResultImage "false")
(Transform "SimilarityTransform")
(NumberOfParameters 7)
(TransformParameters 0.124765 0.434730 0.001912 0.018053 0.015951 -0.003734 0.854469)
(InitialTransformParametersFileName "./TransformParameters.RotationPreAlign.0.txt")
(HowToCombineTransforms "Compose")
// Image specific
(FixedImageDimension 3)
(MovingImageDimension 3)
(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(Size 550 518 570)
(Index 0 0 0)
(Spacing 0.0005000000 0.0005000000 0.0005000000)
(Origin 0.0000000000 0.0000000000 0.0000000000)
(Direction 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000)
(UseDirectionCosines "false")
// SimilarityTransform specific
(CenterOfRotationPoint 0.0622715807 0.0973624433 0.0627662152)
// ResampleInterpolator specific
(ResampleInterpolator "FinalLinearInterpolator")
// Resampler specific
(Resampler "DefaultResampler")
(DefaultPixelValue 0.000000)
(ResultImageFormat "mhd")
(ResultImagePixelType "unsigned char")
(CompressResultImage "false")
run("Apply Transformation (transformix)", "elastixdirectory=/Applications/elastix_macosx64_v4.8 workingdirectory=/Users/tischer/Desktop/tmp inputimagefile=/Users/tischer/Documents/detlev-arendt-clem-registration--data/data/prospr-new/ProSPr6_Ref.tif transformationfile=./TransformParameters.RotationPreAlign.0.txt outputmodality=[Show image]");
cp * /Volumes/cba/tischer/projects/tmp
sed -i '' -e 's/Users\/tischer\/Documents\/detlev-arendt-clem-registration\/transformations-new/g\/cba\/tischer\/projects\/tmp/g' /Volumes/cba/tischer/projects/tmp/*
# generate transformation files for label images, using nn-resampling
cp * label-resampler/
cd label-resampler
# change directories
sed -i '' -e 's/transformations-new/transformations-new\/label-resampler/g' *
# change resampler
sed -i '' -e 's/FinalLinearInterpolator/FinalNearestNeighborInterpolator/g' *
# change pixel output type
sed -i '' -e 's/unsigned char/unsigned short/g' *
FinalLinearInterpolator
# General notes
We are using a SmoothingImagePyramid thus there is not downsampling.
As a consequence the NumberOfSpatialSamples does not have to be adapted to the settings for computing the SmoothingImagePyramid. In fact, I thus changed the name of the corresponding setting in the UI to GaussianSmoothingSigma
It is important to use a good mask in order to restrict the computation to relevant image regions.
In the belly region there are not many nuclei, thus we only rely on the muscles. Thus it could make sense to give them more weight during registration.
I do not have a good feeling for which NumberOfSpatialSamples makes sense. Maybe makes more sense to think in terms of fraction of pixels within mask?
In our mask there are around 40.000.000 pixels.
Maybe less NumberOfSpatialSamples but rather high NumberOfIterations is a good strategy in order to explore more possibilities?
The neuropil is not present one one side of the belly region, thus putting too much weight on it during the registration might lead to bad alignments in this region. However, maybe, once the overall shape is well matched one can increase the weight during fine adjustments done at more fine grained BSplines.
Changing the smoothing ( = ImagePyramidSchedule ) during the registration can be confusing, because the quality metric values will change as well. However, the feeling is that in order to get high accuracy at fine grained BSplines one might need to smooth less?!
Also changing the channel weights will change the overall metric value, the ones of the individual channels stay the same though.
The neuropil shows several features in the ProSPr that are not consistent with the EM segmentation. Maybe it could even be better when we would leave it out from the registration.
# Rotation pre-align
We use the rotation prealign as an inital transformation for the following ones.
It is critical that this is quite good already, otherwise Elastix will not work.
For the new registration we thus used in fact the Similarity transform of the last version as a starting point, because, I could not easily get it to work again from only the manual rotation pre-alignment...
# Similarity
initialTransform: Similarity.0.0.0 (this was quite good already).
## Settings
(MaximumNumberOfIterations 3000)
(NumberOfSpatialSamples 10000)
(ImagePyramidSchedule 15 15 15) // smoothing sigma
(Metric0Weight 1.0 )
(Metric1Weight 1.0 )
(Metric2Weight 1.0 )
(Metric3Weight 1.0 )
### Convergence
0 -0.670076 -0.052695 -0.098571 -0.231706 -0.287104
814 -1.088252 -0.118285 -0.196155 -0.464497 -0.309316
1931 -1.095039 -0.125889 -0.204493 -0.463037 -0.301619
2978 -1.075339 -0.116687 -0.206191 -0.457672 -0.294789
Looked good.
## Observations
The results in the end looked really very good!
It seems to sometimes need that many (over even more) iterations to find a good registration.
It also seems that a strong smoothing is a good strategy (at least for finding an initial transformation), because, I think, it increases the basin of attraction, i.e. gradients are easier to find, especially given our binary input data.
## Quality assessment, comparing to manual
[1] "mean distance [um]: 13.0705100192582"
[1] "median distance [um]: 12.0030001963097"
# Affine
Maybe this can be skipped as there is no scientific reason why one sample should be shrunk in one specific direction more than in an other orthogonal direction ?!
I skipped it.
# BSpline 100
(Transform "BSplineTransform")
(MaximumNumberOfIterations 3000)
(ImagePyramidSchedule 15 15 15)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 100 100 100 )
(Metric0Weight 1.0 )
(Metric1Weight 1.0 )
(Metric2Weight 1.0 )
(Metric3Weight 1.0 )
## Convergence
0 -1.083039 -0.117097 -0.210687 -0.456328 -0.298926
1051 -1.888671 -0.181024 -0.324553 -0.964566 -0.418528
2082 -1.891719 -0.178800 -0.314921 -0.972870 -0.425128
2999 -1.904033 -0.191775 -0.325224 -0.973824 -0.413210
## Quality assessment, comparing to manual
[1] "mean distance [um]: 6.79148843273195"
[1] "median distance [um]: 5.3036845188078"
# BSpline 30
(Transform "BSplineTransform")
(MaximumNumberOfIterations 3000)
(ImagePyramidSchedule 15 15 15) // maybe finer is better?
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 30 30 30 )
(Registration "MultiMetricMultiResolutionRegistration" )
(Metric0Weight 1.0)
(Metric1Weight 1.0)
(Metric2Weight 1.0)
(Metric3Weight 1.0)
## Convergence
0 -1.901998 -0.181355 -0.318081 -0.976434 -0.426128
993 -2.814913 -0.192677 -0.541399 -1.097984 -0.982853
1774 -2.829157 -0.195391 -0.543349 -1.089123 -1.001293
2999 -2.850299 -0.198496 -0.554399 -1.089770 -1.007634
## Quality assessment, comparing to manual
[1] "mean distance [um]: 7.6404333441996"
[1] "median distance [um]: 5.67814229929993"
Without Neuropil, it matches the manual alignment better:
(However, I was also using less smoothing during the registration...)
[1] "mean distance [um]: 6.95459757907805"
[1] "median distance [um]: 5.10188540591226"
# BSpline 10
(Transform "BSplineTransform")
(MaximumNumberOfIterations 10000)
(ImagePyramidSchedule 3 3 3)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 10 10 10 )
(Registration "MultiMetricMultiResolutionRegistration" )
(Metric0Weight 1.0)
(Metric1Weight 0.0)
(Metric2Weight 1.0)
(Metric3Weight 1.0)
## Convergence
0 -1.216981 -0.104610 -0.168183 -0.564945 -0.547425
1039 -1.552749 -0.139684 -0.170087 -0.635585 -0.777481
1995 -1.555570 -0.157091 -0.170651 -0.625069 -0.773410
3360 -1.599939 -0.162178 -0.171022 -0.648801 -0.788959
4245 -1.598560 -0.162070 -0.177205 -0.638421 -0.798069
5224 -1.607016 -0.160768 -0.178598 -0.640116 -0.806132
6897 -1.598460 -0.165485 -0.167907 -0.626949 -0.806026
7218 -1.623194 -0.161837 -0.170983 -0.646790 -0.814567
9999 -1.636316 -0.175230 -0.171565 -0.647740 -0.813346
## Quality assessment, comparing to manual
[1] "mean distance [um]: 6.96336261718872"
[1] "median distance [um]: 5.05191242410221"
Without Neuropil, it matches the manual alignment slightly better.
In some places it also visually looks better, however in others one feels that the Glt1 signal could have been matched better.
[1] "mean distance [um]: 6.85439405211634"
[1] "median distance [um]: 4.90794579734367"
# 23. Sep. 2019
After some discussion we decided to go for a registration attempt that only uses the DAPI, because this is the only channel that is fully consistent.
# Similarity
initialTransform: Similarity.0.0.0 (this was quite good already).
## Settings
(MaximumNumberOfIterations 3000)
(NumberOfSpatialSamples 10000)
(ImagePyramidSchedule 15 15 15) // smoothing sigma
(Metric0Weight 1.0 ) // Only nuclei
### Convergence
0 -0.670076 -0.052695 -0.098571 -0.231706 -0.287104
814 -1.088252 -0.118285 -0.196155 -0.464497 -0.309316
1931 -1.095039 -0.125889 -0.204493 -0.463037 -0.301619
2978 -1.075339 -0.116687 -0.206191 -0.457672 -0.294789
## Quality assessment, comparing to manual
[1] "mean distance [um]: 13.0705100192582"
[1] "median distance [um]: 12.0030001963097"
# Affine
Maybe this can be skipped as there is no scientific reason why one sample should be shrunk in one specific direction more than in an other orthogonal direction ?!
I skipped it.
# BSpline 100
(Transform "BSplineTransform")
(MaximumNumberOfIterations 3000)
(ImagePyramidSchedule 15 15 15)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 100 100 100 )
(Metric0Weight 1.0 )
(Metric1Weight 1.0 )
(Metric2Weight 1.0 )
(Metric3Weight 1.0 )
## Convergence
0 -1.083039 -0.117097 -0.210687 -0.456328 -0.298926
1051 -1.888671 -0.181024 -0.324553 -0.964566 -0.418528
2082 -1.891719 -0.178800 -0.314921 -0.972870 -0.425128
2999 -1.904033 -0.191775 -0.325224 -0.973824 -0.413210
## Quality assessment, comparing to manual
[1] "mean distance [um]: 6.79148843273195"
[1] "median distance [um]: 5.3036845188078"
# BSpline 30
(Transform "BSplineTransform")
(MaximumNumberOfIterations 3000)
(ImagePyramidSchedule 15 15 15) // maybe finer is better?
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 30 30 30 )
(Registration "MultiMetricMultiResolutionRegistration" )
(Metric0Weight 1.0)
(Metric1Weight 1.0)
(Metric2Weight 1.0)
(Metric3Weight 1.0)
## Convergence
0 -1.901998 -0.181355 -0.318081 -0.976434 -0.426128
993 -2.814913 -0.192677 -0.541399 -1.097984 -0.982853
1774 -2.829157 -0.195391 -0.543349 -1.089123 -1.001293
2999 -2.850299 -0.198496 -0.554399 -1.089770 -1.007634
## Quality assessment, comparing to manual
[1] "mean distance [um]: 7.6404333441996"
[1] "median distance [um]: 5.67814229929993"
Without Neuropil, it matches the manual alignment better:
(However, I was also using less smoothing during the registration...)
[1] "mean distance [um]: 6.95459757907805"
[1] "median distance [um]: 5.10188540591226"
# BSpline 10
(Transform "BSplineTransform")
(MaximumNumberOfIterations 10000)
(ImagePyramidSchedule 3 3 3)
(NumberOfSpatialSamples 10000)
(FinalGridSpacingInVoxels 10 10 10 )
(Registration "MultiMetricMultiResolutionRegistration" )
(Metric0Weight 1.0)
(Metric1Weight 0.0)
(Metric2Weight 1.0)
(Metric3Weight 1.0)
## Convergence
-0.405031
## Quality assessment, comparing to manual
[1] "mean distance [um]: 6.96336261718872"
[1] "median distance [um]: 5.05191242410221"
Without Neuropil, it matches the manual alignment slightly better.
In some places it also visually looks better, however in others one feels that the Glt1 signal could have been matched better.
[1] "mean distance [um]: 6.85439405211634"
[1] "median distance [um]: 4.90794579734367"
# Command to produce the output points (example)
# /Applications/elastix_macosx64_v4.8/run_transformix.sh -def /Users/tischer/Desktop/0.5.4/quality-assessment/em-fixed-points.txt -out /Users/tischer/Desktop/0.5.4/quality-assessment -tp /Users/tischer/Desktop/0.5.4/transformations/TransformParameters.BSpline10.0.5.4.txt
file <- "/Users/tischer/Desktop/0.5.4/quality-assessment/outputpoints.txt"
data <- read.table(file, sep = "" , header = F , nrows = 100,
na.strings ="", stringsAsFactors= F)
# transformed ProSPr ( in mm, thus * 1000 to convert to um )
tx <- data[31] * 1000
ty <- data[32] * 1000
tz <- data[33] * 1000
# manually assigned ProSPr
library("readxl")
file <- "/Users/tischer/Desktop/0.5.4/quality-assessment/manually_matched_points_0.5.4.xlsx"
data <- read_excel( file )
mx = data[1]
my = data[2]
mz = data[3]
distance <- sqrt( ( tx - mx )^2 + ( ty - my )^2 + ( tz - mz )^2 )
print( paste( "mean distance [um]:", mean( distance ) ) )
print( paste( "median distance [um]:", median( distance ) ) )
point
43
0.1855 0.167 0.027
0.215 0.115 0.07
0.1388 0.2104 0.0659
0.2045 0.08 0.0905
0.1055 0.2047 0.093
0.2335 0.0545 0.1535
0.089 0.2295 0.1565
0.155919 0.033411 0.236
0.052259 0.154206 0.2505
0.123793 0.062539 0.2735
0.089953 0.107944 0.2745
0.136215 0.115226 0.2645
0.122936 0.083528 0.252
0.10366 0.10109 0.252
0.119081 0.071534 0.211
0.084385 0.113941 0.2165
0.148637 0.076674 0.1525
0.135787 0.090382 0.1525
0.092095 0.15035 0.1525
0.103232 0.135787 0.1525
0.137928 0.12979 0.099
0.16381 0.150083 0.108
0.198256 0.139327 0.0685
0.160797 0.19186 0.071
0.204651 0.043397 0.154
0.067608 0.208762 0.158
0.181811 0.047965 0.232
0.216 0.149 0.0138
0.172 0.199 0.013
0.144809 0.134302 0.0415
0.236171 0.168563 0.063
0.197799 0.217442 0.0615
0.233887 0.149377 0.0655
0.177243 0.215615 0.07
0.192303 0.156196 0.113
0.190298 0.154592 0.124
0.17191 0.176791 0.124
0.173314 0.177794 0.1135
0.156 0.176724 0.1167
0.186 0.140082 0.1157
0.217802 0.149974 0.0155
0.172444 0.200035 0.0145
0.064923 0.180609 0.2515
\ No newline at end of file
File added
# manually_matched_points.xlsx
From Hernando ...
# em-fixed-points
Taken from manually_matched_points.xlsx
Changed to mm units
Formatted as input to Transformix
# outputpoints.txt
Transformed points as created by Transformix
# Transformix
(From Elastix manual)
Besides using transformix for deforming images, you can also use transformix to evaluate the trans- formation Tμ(x) at some points x ∈ ΩF . This means that the input points are specified in the fixed image domain (!), since the transformation direction is from fixed to moving image, as explained in Section 2.6. If you want to deform a set of user-specified points, the appropriate call is:
transformix -def inputPoints.txt -out outputDirectory -tp TransformParameters.txt
This will create a file outputpoints.txt containing the input points x and the transformed points Tμ(x) (given as voxel indices of the fixed image and additionally as physical coordinates), the displacement vector Tμ(x) − x (in physical coordinates), and, if -in inputImage.ext is also specified, the transformed output points as indices of the input image1. The inputPoints.txt file should have the following structure:
<index, point>
<number of points>
point1 x point1 y [point1 z]
point2 x point2 y [point2 z] ...
The first line indicates whether the points are given as “indices” (of the fixed image), or as “points” (in physical coordinates). The second line stores the number of points that will be specified. After that the point data is given.
## Example calls
### Version 9.9.9
#### Similarity
#### BSpline10
/Applications/elastix_macosx64_v4.8/run_transformix.sh -def /Users/tischer/Desktop/9.9.9/quality-assessment/em-fixed-points.txt -out /Users/tischer/Desktop/9.9.9/quality-assessment -tp /Users/tischer/Desktop/9.9.9/transformations/TransformParameters.BSpline10.9.9.9.txt
Point 0 ; InputIndex = [ 337 303 49 ] ; InputPoint = [ 0.185500 0.167000 0.027000 ] ; OutputIndexFixed = [ 159 82 113 ] ; OutputPoint = [ 0.087649 0.044883 0.062235 ] ; Deformation = [ -0.097851 -0.122117 0.035235 ]
Point 1 ; InputIndex = [ 391 209 127 ] ; InputPoint = [ 0.215000 0.115000 0.070000 ] ; OutputIndexFixed = [ 55 147 129 ] ; OutputPoint = [ 0.030538 0.080993 0.070916 ] ; Deformation = [ -0.184462 -0.034007 0.000916 ]
Point 2 ; InputIndex = [ 252 382 120 ] ; InputPoint = [ 0.138800 0.210400 0.065900 ] ; OutputIndexFixed = [ 266 150 124 ] ; OutputPoint = [ 0.146334 0.082572 0.068358 ] ; Deformation = [ 0.007534 -0.127828 0.002458 ]
Point 3 ; InputIndex = [ 372 145 164 ] ; InputPoint = [ 0.204500 0.080000 0.090500 ] ; OutputIndexFixed = [ 33 212 102 ] ; OutputPoint = [ 0.017967 0.116892 0.056387 ] ; Deformation = [ -0.186533 0.036892 -0.034113 ]
Point 4 ; InputIndex = [ 192 372 169 ] ; InputPoint = [ 0.105500 0.204700 0.093000 ] ; OutputIndexFixed = [ 279 214 98 ] ; OutputPoint = [ 0.153615 0.117628 0.053685 ] ; Deformation = [ 0.048115 -0.087072 -0.039315 ]
Point 5 ; InputIndex = [ 424 99 279 ] ; InputPoint = [ 0.233500 0.054500 0.153500 ] ; OutputIndexFixed = [ 3 310 143 ] ; OutputPoint = [ 0.001687 0.170781 0.078448 ] ; Deformation = [ -0.231813 0.116281 -0.075052 ]
Point 6 ; InputIndex = [ 162 417 284 ] ; InputPoint = [ 0.089000 0.229500 0.156500 ] ; OutputIndexFixed = [ 308 310 137 ] ; OutputPoint = [ 0.169592 0.170825 0.075374 ] ; Deformation = [ 0.080592 -0.058675 -0.081126 ]
Point 7 ; InputIndex = [ 283 61 429 ] ; InputPoint = [ 0.155919 0.033411 0.236000 ] ; OutputIndexFixed = [ 48 472 129 ] ; OutputPoint = [ 0.026438 0.259812 0.070980 ] ; Deformation = [ -0.129481 0.226401 -0.165020 ]
Point 8 ; InputIndex = [ 95 280 455 ] ; InputPoint = [ 0.052259 0.154206 0.250500 ] ; OutputIndexFixed = [ 268 469 128 ] ; OutputPoint = [ 0.147595 0.257855 0.070488 ] ; Deformation = [ 0.095336 0.103649 -0.180012 ]
Point 9 ; InputIndex = [ 225 114 497 ] ; InputPoint = [ 0.123793 0.062539 0.273500 ] ; OutputIndexFixed = [ 123 515 168 ] ; OutputPoint = [ 0.067946 0.283169 0.092428 ] ; Deformation = [ -0.055847 0.220630 -0.181072 ]
Point 10 ; InputIndex = [ 163 196 499 ] ; InputPoint = [ 0.089953 0.107944 0.274500 ] ; OutputIndexFixed = [ 191 511 169 ] ; OutputPoint = [ 0.105055 0.281290 0.093096 ] ; Deformation = [ 0.015102 0.173346 -0.181404 ]
Point 11 ; InputIndex = [ 247 209 481 ] ; InputPoint = [ 0.136215 0.115226 0.264500 ] ; OutputIndexFixed = [ 160 411 172 ] ; OutputPoint = [ 0.087919 0.226142 0.094664 ] ; Deformation = [ -0.048296 0.110916 -0.169836 ]
Point 12 ; InputIndex = [ 223 152 458 ] ; InputPoint = [ 0.122936 0.083528 0.252000 ] ; OutputIndexFixed = [ 136 472 141 ] ; OutputPoint = [ 0.074845 0.259935 0.077388 ] ; Deformation = [ -0.048091 0.176407 -0.174612 ]
Point 13 ; InputIndex = [ 188 184 458 ] ; InputPoint = [ 0.103660 0.101090 0.252000 ] ; OutputIndexFixed = [ 173 471 139 ] ; OutputPoint = [ 0.095088 0.258963 0.076454 ] ; Deformation = [ -0.008572 0.157873 -0.175546 ]
Point 14 ; InputIndex = [ 216 130 383 ] ; InputPoint = [ 0.119081 0.071534 0.211000 ] ; OutputIndexFixed = [ 117 434 85 ] ; OutputPoint = [ 0.064153 0.238986 0.046796 ] ; Deformation = [ -0.054928 0.167452 -0.164204 ]
Point 15 ; InputIndex = [ 153 207 393 ] ; InputPoint = [ 0.084385 0.113941 0.216500 ] ; OutputIndexFixed = [ 195 435 87 ] ; OutputPoint = [ 0.107443 0.239297 0.048091 ] ; Deformation = [ 0.023058 0.125356 -0.168409 ]
Point 16 ; InputIndex = [ 270 139 277 ] ; InputPoint = [ 0.148637 0.076674 0.152500 ] ; OutputIndexFixed = [ 86 323 72 ] ; OutputPoint = [ 0.047200 0.177591 0.039638 ] ; Deformation = [ -0.101437 0.100917 -0.112862 ]
Point 17 ; InputIndex = [ 247 164 277 ] ; InputPoint = [ 0.135787 0.090382 0.152500 ] ; OutputIndexFixed = [ 116 328 61 ] ; OutputPoint = [ 0.063920 0.180606 0.033404 ] ; Deformation = [ -0.071867 0.090224 -0.119096 ]
Point 18 ; InputIndex = [ 167 273 277 ] ; InputPoint = [ 0.092095 0.150350 0.152500 ] ; OutputIndexFixed = [ 228 320 65 ] ; OutputPoint = [ 0.125364 0.176143 0.035539 ] ; Deformation = [ 0.033269 0.025793 -0.116961 ]
Point 19 ; InputIndex = [ 188 247 277 ] ; InputPoint = [ 0.103232 0.135787 0.152500 ] ; OutputIndexFixed = [ 196 323 58 ] ; OutputPoint = [ 0.107977 0.177558 0.032173 ] ; Deformation = [ 0.004745 0.041771 -0.120327 ]
Point 20 ; InputIndex = [ 251 236 180 ] ; InputPoint = [ 0.137928 0.129790 0.099000 ] ; OutputIndexFixed = [ 156 225 56 ] ; OutputPoint = [ 0.085970 0.123822 0.030889 ] ; Deformation = [ -0.051958 -0.005968 -0.068111 ]
Point 21 ; InputIndex = [ 298 273 196 ] ; InputPoint = [ 0.163810 0.150083 0.108000 ] ; OutputIndexFixed = [ 155 214 107 ] ; OutputPoint = [ 0.085436 0.117563 0.058691 ] ; Deformation = [ -0.078374 -0.032520 -0.049309 ]
Point 22 ; InputIndex = [ 360 253 124 ] ; InputPoint = [ 0.198256 0.139327 0.068500 ] ; OutputIndexFixed = [ 108 143 128 ] ; OutputPoint = [ 0.059621 0.078962 0.070282 ] ; Deformation = [ -0.138635 -0.060365 0.001782 ]
Point 23 ; InputIndex = [ 292 349 129 ] ; InputPoint = [ 0.160797 0.191860 0.071000 ] ; OutputIndexFixed = [ 211 153 130 ] ; OutputPoint = [ 0.116368 0.084316 0.071662 ] ; Deformation = [ -0.044429 -0.107544 0.000662 ]
Point 24 ; InputIndex = [ 372 79 280 ] ; InputPoint = [ 0.204651 0.043397 0.154000 ] ; OutputIndexFixed = [ 5 328 107 ] ; OutputPoint = [ 0.003011 0.180716 0.058895 ] ; Deformation = [ -0.201640 0.137319 -0.095105 ]
Point 25 ; InputIndex = [ 123 379 287 ] ; InputPoint = [ 0.067608 0.208762 0.158000 ] ; OutputIndexFixed = [ 307 329 102 ] ; OutputPoint = [ 0.168974 0.181127 0.056038 ] ; Deformation = [ 0.101366 -0.027635 -0.101962 ]
Point 26 ; InputIndex = [ 330 87 422 ] ; InputPoint = [ 0.181811 0.047965 0.232000 ] ; OutputIndexFixed = [ 50 435 155 ] ; OutputPoint = [ 0.027793 0.239221 0.085542 ] ; Deformation = [ -0.154018 0.191256 -0.146458 ]
Point 27 ; InputIndex = [ 392 271 25 ] ; InputPoint = [ 0.216000 0.149000 0.013800 ] ; OutputIndexFixed = [ 103 36 117 ] ; OutputPoint = [ 0.056498 0.019921 0.064134 ] ; Deformation = [ -0.159502 -0.129079 0.050334 ]
Point 28 ; InputIndex = [ 312 362 24 ] ; InputPoint = [ 0.172000 0.199000 0.013000 ] ; OutputIndexFixed = [ 220 41 109 ] ; OutputPoint = [ 0.120980 0.022412 0.059950 ] ; Deformation = [ -0.051020 -0.176588 0.046950 ]
Point 29 ; InputIndex = [ 263 244 75 ] ; InputPoint = [ 0.144809 0.134302 0.041500 ] ; OutputIndexFixed = [ 157 124 42 ] ; OutputPoint = [ 0.086675 0.068171 0.022936 ] ; Deformation = [ -0.058134 -0.066131 -0.018564 ]
Point 30 ; InputIndex = [ 429 306 114 ] ; InputPoint = [ 0.236171 0.168563 0.063000 ] ; OutputIndexFixed = [ 105 115 198 ] ; OutputPoint = [ 0.057835 0.063167 0.109096 ] ; Deformation = [ -0.178336 -0.105396 0.046096 ]
Point 31 ; InputIndex = [ 359 395 112 ] ; InputPoint = [ 0.197799 0.217442 0.061500 ] ; OutputIndexFixed = [ 208 117 203 ] ; OutputPoint = [ 0.114726 0.064389 0.111448 ] ; Deformation = [ -0.083073 -0.153053 0.049948 ]
Point 32 ; InputIndex = [ 425 271 119 ] ; InputPoint = [ 0.233887 0.149377 0.065500 ] ; OutputIndexFixed = [ 83 131 180 ] ; OutputPoint = [ 0.045453 0.072322 0.099116 ] ; Deformation = [ -0.188434 -0.077055 0.033616 ]
Point 33 ; InputIndex = [ 322 392 127 ] ; InputPoint = [ 0.177243 0.215615 0.070000 ] ; OutputIndexFixed = [ 235 142 176 ] ; OutputPoint = [ 0.129265 0.077955 0.096878 ] ; Deformation = [ -0.047978 -0.137660 0.026878 ]
Point 34 ; InputIndex = [ 349 284 205 ] ; InputPoint = [ 0.192303 0.156196 0.113000 ] ; OutputIndexFixed = [ 133 213 154 ] ; OutputPoint = [ 0.072989 0.117052 0.084599 ] ; Deformation = [ -0.119314 -0.039144 -0.028401 ]
Point 35 ; InputIndex = [ 346 281 225 ] ; InputPoint = [ 0.190298 0.154592 0.124000 ] ; OutputIndexFixed = [ 132 234 156 ] ; OutputPoint = [ 0.072393 0.128587 0.085916 ] ; Deformation = [ -0.117905 -0.026005 -0.038084 ]
Point 36 ; InputIndex = [ 312 321 225 ] ; InputPoint = [ 0.171910 0.176791 0.124000 ] ; OutputIndexFixed = [ 182 231 156 ] ; OutputPoint = [ 0.100322 0.127309 0.085866 ] ; Deformation = [ -0.071588 -0.049482 -0.038134 ]
Point 37 ; InputIndex = [ 315 323 206 ] ; InputPoint = [ 0.173314 0.177794 0.113500 ] ; OutputIndexFixed = [ 180 215 149 ] ; OutputPoint = [ 0.099177 0.118321 0.081988 ] ; Deformation = [ -0.074137 -0.059473 -0.031512 ]
Point 38 ; InputIndex = [ 283 321 212 ] ; InputPoint = [ 0.156000 0.176724 0.116700 ] ; OutputIndexFixed = [ 194 229 129 ] ; OutputPoint = [ 0.106568 0.126148 0.070903 ] ; Deformation = [ -0.049432 -0.050576 -0.045797 ]
Point 39 ; InputIndex = [ 338 255 210 ] ; InputPoint = [ 0.186000 0.140082 0.115700 ] ; OutputIndexFixed = [ 121 227 129 ] ; OutputPoint = [ 0.066555 0.124924 0.070977 ] ; Deformation = [ -0.119445 -0.015158 -0.044723 ]
Point 40 ; InputIndex = [ 396 273 28 ] ; InputPoint = [ 0.217802 0.149974 0.015500 ] ; OutputIndexFixed = [ 101 38 121 ] ; OutputPoint = [ 0.055659 0.020711 0.066854 ] ; Deformation = [ -0.162143 -0.129263 0.051354 ]
Point 41 ; InputIndex = [ 313 363 26 ] ; InputPoint = [ 0.172444 0.200035 0.014500 ] ; OutputIndexFixed = [ 221 42 113 ] ; OutputPoint = [ 0.121732 0.022847 0.061959 ] ; Deformation = [ -0.050712 -0.177188 0.047459 ]
Point 42 ; InputIndex = [ 118 328 457 ] ; InputPoint = [ 0.064923 0.180609 0.251500 ] ; OutputIndexFixed = [ 275 439 153 ] ; OutputPoint = [ 0.151138 0.241781 0.084222 ] ; Deformation = [ 0.086215 0.061172 -0.167278 ]
{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf600
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\f0\fs24 \cf0 ## 0.0.0\
\
Using: nuclei, muscles, neuropil\
\
Measured against: Hernando\'92s curated list:\
\
[1] "mean distance [um]: 4.61557446590928" \
[1] "median distance [um]: 4.27639300488525"\
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\cf0 ## 9.9.9\
\
Using: nuclei\
\
Measured against: Hernando\'92s curated list:\
\
[1] "mean distance [um]: 4.0179562559261" \
[1] "median distance [um]: 3.23701869009124"\
\
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment