Skip to content
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

Added reading each ROI group #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

cudmore
Copy link

@cudmore cudmore commented Nov 21, 2020

This PR adds reading and return the group for each ROI. The ROI group is useful for segregating ROIs into, well, different groups.

I have not thoroughly tested this code but it is working for my ROI .zip files!!!

Copy link
Collaborator

@scottclowe scottclowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I have added comments requesting changes to the code formatting. It is bad practice in Python to comment on every line in the code. Many operations are self-descriptive and comments for these only add fluff; comments should be directed towards explaining complex or counter-intuitive lines or blocks of code. Also, we do not need to keep old code commented out. The code is under version control, which is much better for tracking changes and what code used to look like before changes! Additionally, note that trailing spaces should be avoided.

Beyond the cosmetic changes to the main code, we will also need more changes before the PR can be completed.

  1. Unit tests currently fail, and need to be fixed. In order to fix these, the json files indicating expected outputs will need to be adjusted to contain the expected group value.
  2. A new unit test will need to be added which makes sure the new code runs correctly for more than one group value (since I expect all the current unit tests will have a group value of 0).

@@ -316,9 +316,13 @@ def extract_basic_roi_data(data):
overlayFontSize = get_uint16(data, hdr2Offset + HEADER_OFFSET['OVERLAY_FONT_SIZE'])
imageOpacity = get_byte(data, hdr2Offset + HEADER_OFFSET['IMAGE_OPACITY'])
imageSize = get_uint32(data, hdr2Offset + HEADER_OFFSET['IMAGE_SIZE'])
# abb, read group from file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the need for this comment; this is one of many bytes being loaded all in the same way, and there is no need to comment on this particular one. Not sure why it begins with "abb," either. What does this mean?

@@ -316,9 +316,13 @@ def extract_basic_roi_data(data):
overlayFontSize = get_uint16(data, hdr2Offset + HEADER_OFFSET['OVERLAY_FONT_SIZE'])
imageOpacity = get_byte(data, hdr2Offset + HEADER_OFFSET['IMAGE_OPACITY'])
imageSize = get_uint32(data, hdr2Offset + HEADER_OFFSET['IMAGE_SIZE'])
# abb, read group from file
group = get_byte(data, hdr2Offset + HEADER_OFFSET['AVAILABLE_BYTE1'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace HEADER_OFFSET['AVAILABLE_BYTE1'] with HEADER_OFFSET['GROUP'] (both here, and of course also where the offset is defined. This is in keeping with our source code reference.

Comment on lines +323 to +325
# abb, append group to tuple
#roi_props = (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size)
roi_props = (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size, group)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the comment, or to include the deleted line as a comment.

Suggested change
# abb, append group to tuple
#roi_props = (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size)
roi_props = (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size, group)
roi_props = (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size, group)

Comment on lines +483 to +485
# abb, append group to returned (assigned) tuple
#roi, (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size) = extract_basic_roi_data(data)
roi, (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size, group) = extract_basic_roi_data(data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this comment, or to include deleted line as a comment.

Suggested change
# abb, append group to returned (assigned) tuple
#roi, (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size) = extract_basic_roi_data(data)
roi, (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size, group) = extract_basic_roi_data(data)
roi, (hdr2Offset, n_coordinates, roi_type, channel, slice, frame, position, version, subtype, size, group) = extract_basic_roi_data(data)

Comment on lines +487 to +489
# abb, add group to dict
roi['group'] = group

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for comment describing self-evident operation. Empty lines should not contain spaces.

Suggested change
# abb, add group to dict
roi['group'] = group
roi['group'] = group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants