-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reader update #5
Comments
This seems fine. Given that we don't have an official release here yet, I am not too worried about breaking backwards compatibility In general, we need to incorporate the affine orientation information from the headers to make sure things are oriented correctly. As I am sure you are aware, left vs. right is hard to visually distinguish for brains, so some care is needed to make sure it is correct! |
In the images I mainly use I can clearly identify the left and right side. As of now left right was always displayed correctly. Only top and bottom were always inverted. Did this happen for your images? As of now napari supports affine transformations. I already tested an implementation. Sadly if given an affine matrix the scale parameter is no longer used and my flip of top and bottom does no longer work. |
As mentioned in the writer thread it will be beneficial to switch from storing the header and affine matrix in |
@effigies I try to find a robust method to get the reading directions for each dimension from the image header. I hope to find a solution working with each image format. I want to do this to stop displaying the nifti files upside down in napari. |
Could you clarify what you mean? What is the format of a "reading direction"? We may already have something like what you need in https://github.com/nipy/nibabel/blob/master/nibabel/orientations.py, but in any event, it should not be difficult to calculate it from the affine. |
The reading direction of each array dimension in a nifti file is documented in the qform and sform if I'm right. (Sanner, unknown, etc.) I don't realy know if the other formats have a similar information in their header. I would like to include a function to detect this reading direction to always display the images in the right orientation. In general I try to make napari directional aware like FSL or other medical viewers. I hope I could explain it in a clearer way now. Edit: |
The affine matrix doesn't encode any information about the temporal dimension. Almost all formats have their spatial axes first, with MINC being the primary exception. We have a function for determining this: nibabel.imageclasses.spatial_axes_first (code). |
I know that the affine matrix does not include temporal information. To use affine transformation in napari with 4D images I extend the matrix to 5x5. That works fine by the way. I would like to display anterior to posterior in the z axis after loading into napari. To achieve this I need to shift the axis order from xyz to zyx. But if I do this the affine matrix does no longer fit. To shift the translation part of the matrix is no problem but with the 3x3 scale / rotate / sheer matrix part I hit my limits. I thought to transpose the matrix would do the trick but I suppose I was naive. Everything I tried did not lead to a correctly transformed image. |
I uploaded an updated version of the reader to a new branch. It follows the discussed script name convention and supports image orientation. The original image object is now stored in the metadata. Affine transformation is not included as napari can not correctly display the 2D views if non-orthogonal slicing is needed. |
@effigies the affine matrix always casts the image to the RAS orientation right? |
Hi,
I have a question regarding the dimension order the reader uses. Wouldn't it be convenient if we change the axis order to the order napari uses (reader at the moment: t,x,y,z vs napari: t,z,y,x). This way the image gets displayed in a more natural way.
I use to flip the y axis to display the patients back at the bottom, as the reading direction of this dimension differ between my files and napari. Is this a general problem or just specific for my files?
Best Regards
Christopher
The text was updated successfully, but these errors were encountered: