-
Notifications
You must be signed in to change notification settings - Fork 8
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
Raw input preview #356
Raw input preview #356
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if dimensionality == 3: | ||
# read the centre slice | ||
slice_size = shape[1]*shape[0] | ||
offset = shape[2]*slice_size//2 | ||
|
||
rawfname = os.path.join(tempfile.gettempdir(),"test.raw") | ||
|
||
offset = offset * bytes_per_element | ||
slices_to_read = 1 | ||
if shape[2] > 1: | ||
slices_to_read = 2 | ||
with open(self.fname, 'br') as f: | ||
f.seek(offset) | ||
raw_data = f.read(slice_size*bytes_per_element* slices_to_read) | ||
with open(rawfname, 'wb') as f2: | ||
f2.write(raw_data) | ||
|
||
reader2 = vtk.vtkImageReader2() | ||
reader2.SetFileName(rawfname) | ||
|
||
vtktype = Converter.dtype_name_to_vtkType[dt.name] | ||
reader2.SetDataScalarType(vtktype) | ||
|
||
if isBigEndian: | ||
reader2.SetDataByteOrderToBigEndian() | ||
else: | ||
reader2.SetDataByteOrderToLittleEndian() | ||
|
||
reader2.SetFileDimensionality(len(shape)) | ||
vtkshape = shape[:] | ||
if not isFortran: | ||
# need to reverse the shape (again) | ||
vtkshape = shape[::-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using the RawCroppedReader here instead, to avoid repetition of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the cilRawCroppedReader
but it gave the wrong output, which means that selecting from the dialog Fortran or C-order would preview a correct but different slice. In this case the preview would not be useful and the user might select open with the wrong setting.
This did not happen with the above code.
I updated cilRawCroppedReader
with the code above. I haven't done more testing of this except using cilviewer
to load a raw file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paskino is this conversation resolved or should we do more tests?
Co-authored-by: Laura Murgatroyd <[email protected]>
central_slice = 'z' | ||
else: | ||
shape = (dimZ, dimY, dimX) | ||
central_slice = 'x' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added
if dimensionality == 3: if isFortran: shape = (dimX, dimY, dimZ) central_slice = 'z' else: shape = (dimZ, dimY, dimX) central_slice = 'x'
This means that the axes in the preview are wrong. We need to rotate them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not test the code for dimensionality = 2, I need data for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now added to the preview.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that we should also swap the axis labels when loading the whole image. This would be done in the application that uses the viewer, not in this dialog.
… raw_input_preview
remove commented out code
7418344
to
c210597
Compare
Data has been shared in Tomography-Data, DVC The "file 40891_8bit_1431-1260-1335" is not uploaded correctly with the settings indicated by @lauramurgatroyd By editing the fortran ordering the image is uploaded correctly, this work is currently stored in another branch |
Probably we should rename |
If we do so we should add an option in the app where the user can rename the labels eg. when saving images for research papers and investigating their system |
Yes, but that would be and advanced feature. So far I'd be happy if the dialog required the appropriate information and used it well. The axis labels defaults could, on first instance, remain X,Y and Z. |
The probable culprit of the failing unit tests is the change in the |
I opened a new issue for this #406. The topic should be addressed in #390 as we will not address this here. I opened a new issue #407 for the advanced feature |
Closed as superseded by #410 |
Should close #383
This PR did not pass the tests. Part of the work has been used in a new PR #410.
Adds preview button to the raw input dialog.
hides slider in the preview dialog (see hide option for slider #384)
hides one of the axes in 2D viewer preview (merged hide axis when creating viewer 2D #408)
Tested on knee data and not working. A working version has been found in another branch after removing the fortran ordering. (@paskino)
add unit tests (or not?)
run unit tests. At the moment many are failing (@paskino)
Not to be done in this PR: