Add error message for impossible roi request to ZeissDataReader and fix sign error when negative values passed to ROI#2244
Add error message for impossible roi request to ZeissDataReader and fix sign error when negative values passed to ROI#2244lauramurgatroyd wants to merge 7 commits intomasterfrom
Conversation
gfardell
left a comment
There was a problem hiding this comment.
Are there any unit tests that need updating here?
| idx = zeiss_data_order[key] | ||
| if roi[key] != -1: | ||
| if key == AcquisitionDimension.ANGLE: | ||
| if roi[key][1] > default_roi[0][1]: |
There was a problem hiding this comment.
The stop could be a negative, i.e. -10 would be the N-10. Would these checks pass? has the value already been normalised?
There was a problem hiding this comment.
currently its only dealing with the stop being negative. I'm now updating it to allow a negative start as well
|
Just updated to make sure it can take negative start and stop values, plus added unit tests for these cases |
hrobarts
left a comment
There was a problem hiding this comment.
Hi Laura, this looks good to me. Is it worth adding something about the negative indexing in the docstring?
| For ImageData to skip files or to change number of files to load, | ||
| adjust ``vertical``. E.g. ``'vertical': (100, 300)`` will skip first 100 files | ||
| and will load 200 files. | ||
|
|
||
| ``'axis_label': -1`` is a shortcut to load all elements along axis. | ||
|
|
||
| ``start`` and ``end`` can be specified as ``None`` which is equivalent | ||
| to ``start = 0`` and ``end = load everything to the end``, respectively. |
There was a problem hiding this comment.
| For ImageData to skip files or to change number of files to load, | |
| adjust ``vertical``. E.g. ``'vertical': (100, 300)`` will skip first 100 files | |
| and will load 200 files. | |
| ``'axis_label': -1`` is a shortcut to load all elements along axis. | |
| ``start`` and ``end`` can be specified as ``None`` which is equivalent | |
| to ``start = 0`` and ``end = load everything to the end``, respectively. | |
| ``start`` and ``end`` can be negative numbers, with the same behaviour | |
| as numpy slicing, with -x meaning x many from the end. | |
| e.g on a dimension with 10 elements ``start=-3`` and ``stop=-1`` | |
| is equivalent to ``start=7``, ``stop=9`` |
There was a problem hiding this comment.
Hi @hrobarts sorry the suggestion looks weird but is line 53 onwards sufficient for adding the details of negative values in the roi?
There was a problem hiding this comment.
I think you should keep it simple. We use it all over the place (maybe check slicer/binner doc strings for consistency). I would think just saying it accepts negative indices is sufficient.
The main point is the start index is included in the range, the stop index won't be included in the range, I've seen people put (0,-1) not realising that is cropping, whereas (100,-100) will be a symmetric crop.
I think it's easier to convey in a code example snippet than text though.
If you want to explain the indexing maybe refer to: https://numpy.org/doc/stable/user/basics.indexing.html but I would class it as a language feature.
Added a note about fixing the behavior of `ZeissDataReader` with negative ROI values. Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
Description
Closes #2240
Example Usage
Contribution Notes
Changes
Testing you performed
Related issues/links
Checklist