You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm pretty sure this will not be responded, but I report this anyway, hoping that this could save someone else's precious time.
I think I found an error in the code.
In sliceBrowser.m, when the tissue image is big, imresize() is called and the image is shrunk to the same size as the reference atlas image eg. [800, 1140] for coronal image.
This shrunk image will be used for the affine transform later.
functionud= updateSliceImage(ud)
title_ending ='';
processed_image_name = ud.processed_image_names{ud.slice_num};
current_slice_image = flip(imread(fullfile(ud.processed_images_folder, processed_image_name)),1);
% reduce to 3 channels at most
color_channels = min( 3, size(current_slice_image,3));
current_slice_image = current_slice_image(:,:,1:color_channels);
% reduce to reference atlas sizeif size(current_slice_image,1) >ud.ref_size(1)+2|| size(current_slice_image,2) >ud.ref_size(2)+2
disp(['shrinking image to reference size ' num2str(ud.ref_size(1)) ' x ' num2str(ud.ref_size(2)) ' pxl'])
current_slice_image = imresize(current_slice_image, ud.ref_size);
end
set(ud.im, 'CData', current_slice_image);
However in AtlasTransformBrowser.m, when the result of the transform are saved as an image, the image is directly loaded with imread() and used for transformation by imwarp() without resizing before. So the transfrom will give you very strange results depending on the aspect ratio of your tissue image. Perhaps imref2d was meant to avoid this problem but in my hands that's not working and curr_slice_trans is very much skewed.
It is commented out, but current_slice_image = flip(get(ud_slice.im, 'CData'),1); will give you the image in the size of [840, 1140] and should work better. Otherwise we need to add imresize() around here.
Another way to fix this is to get rid of imresize() altogether.
Although it looks terribly wrong and confusing, the transform points are saved correctly, so the actual damage seems small.
A: Slice Viewer. Note that the image is shrunk horizontally due to imresize(). For the purpose of validating the performance of SharpTrack, I am using the images from the printed atlas instead of microscopic images. B: Atlas viewer. Overlaid with the transformed slice image. Note that the affine transformation is successful overall. C: The exported TIF image found in the transformations folder from the same transform as in panel C. The scaling of the transform is messed up because of the ignorance of the effect of imresize() to the size of [840, 1140]. The original image I used had the dimension of [969, 1761]. D: The exported TIF image after a fix by uncommenting current_slice_image = flip(get(ud_slice.im, 'CData'),1). This issue may not be obvious if your tissue image has roughly the same aspect ratio as the atlas image or they are smaller than the atlas image (because, in that case, imresize() will not be used).
The text was updated successfully, but these errors were encountered:
I'm pretty sure this will not be responded, but I report this anyway, hoping that this could save someone else's precious time.
I think I found an error in the code.
In
sliceBrowser.m
, when the tissue image is big,imresize()
is called and the image is shrunk to the same size as the reference atlas image eg. [800, 1140] for coronal image.This shrunk image will be used for the affine transform later.
https://github.com/cortex-lab/allenCCF/blob/0bbff55fc906fd3f023da81ce1d0e4b8726d4fd0/Browsing%20Functions/sliceBrowser.m#L110C1-L124C47
However in
AtlasTransformBrowser.m
, when the result of the transform are saved as an image, the image is directly loaded withimread()
and used for transformation byimwarp()
without resizing before. So the transfrom will give you very strange results depending on the aspect ratio of your tissue image. Perhapsimref2d
was meant to avoid this problem but in my hands that's not working andcurr_slice_trans
is very much skewed.https://github.com/cortex-lab/allenCCF/blob/0bbff55fc906fd3f023da81ce1d0e4b8726d4fd0/Browsing%20Functions/AtlasTransformBrowser.m#L696C9-L700C101
It is commented out, but
current_slice_image = flip(get(ud_slice.im, 'CData'),1);
will give you the image in the size of [840, 1140] and should work better. Otherwise we need to addimresize()
around here.Another way to fix this is to get rid of
imresize()
altogether.Although it looks terribly wrong and confusing, the transform points are saved correctly, so the actual damage seems small.
A: Slice Viewer. Note that the image is shrunk horizontally due to
imresize()
. For the purpose of validating the performance of SharpTrack, I am using the images from the printed atlas instead of microscopic images. B: Atlas viewer. Overlaid with the transformed slice image. Note that the affine transformation is successful overall. C: The exported TIF image found in thetransformations
folder from the same transform as in panel C. The scaling of the transform is messed up because of the ignorance of the effect ofimresize()
to the size of [840, 1140]. The original image I used had the dimension of [969, 1761]. D: The exported TIF image after a fix by uncommentingcurrent_slice_image = flip(get(ud_slice.im, 'CData'),1)
. This issue may not be obvious if your tissue image has roughly the same aspect ratio as the atlas image or they are smaller than the atlas image (because, in that case,imresize()
will not be used).The text was updated successfully, but these errors were encountered: