-
Notifications
You must be signed in to change notification settings - Fork 25
Adds new variable that outputs the gray value corresponding to the position of the fly in the grayscale mask #84
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
Conversation
…s values after the affine transformation
… in of the position of the fly on the mask.
…nd type, otherwise regions = mask and throw exceptions
src/ethoscope/core/roi.py
Outdated
| :param value: an optional value to be save for this ROI (e.g. to define left and right side) | ||
| :param orientation: Optional orientation Not implemented yet | ||
| :param regions: Optional sub-regions within the ROI. Not implemented yet | ||
| :param regions: Optional sub-regions within the ROI. |
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.
We need to make it clear, in the doc, that regions is a 2d array and that regions is a greyscale map / LUT. I.e. each pixel is the value of region in X,Y
src/ethoscope/core/roi.py
Outdated
| if gray_value is None: | ||
| return 0 | ||
| else: | ||
| print gray_value, self.idx |
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.
remove print
src/ethoscope/core/variables.py
Outdated
| out += oy | ||
| return YPosVariable(out) | ||
|
|
||
| class RegionPosVariable(BaseIntVariable): |
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.
rename to RegionValueVariable: Pos suggest we are dealing with a position
| phi_var = PhiVariable(int(round(angle))) | ||
| # mlogl = mLogLik(int(distance*1000)) | ||
|
|
||
| gray_region = self._roi.find_region(x_var, y_var) |
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.
great idea, gray -> grey
src/ethoscope/core/roi.py
Outdated
| self._regions = regions | ||
| else: | ||
| self._regions = self._mask | ||
| logging.warning('The regions argument of the roi has to be an numpy.ndarray that has equal size with the mask of the roi') |
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.
make error instead:
logging.error("xxxx")
raise Exception("Regions and Mask hvae different sizes!")
src/ethoscope/core/roi.py
Outdated
|
|
||
| if regions is None: | ||
| self._regions = self._mask | ||
| elif (regions.size == self._mask.size) & (type(regions) == type(self._mask)): |
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.
use ndarray.shape to do all in one go
src/ethoscope/core/roi.py
Outdated
| def find_region(self, x, y): | ||
| try: | ||
| gray_value = self._regions[x, y] | ||
| except: |
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.
always print exception as a warning:
try:
gray_value = self._regions[x, y]
except Exception as e:
logging.warning(e)
...
Also you can specify the type of exceptions Expect IndexError as e.
src/ethoscope/core/variables.py
Outdated
| """ | ||
| Type encoding a region inside the ROI, represented as the grayscale value of the pixel on which sits the center of the detected object. | ||
| """ | ||
| header_name = "gray_region" |
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.
header_name = "sub_roi"
src/ethoscope/core/variables.py
Outdated
| Type encoding a region inside the ROI, represented as the grayscale value of the pixel on which sits the center of the detected object. | ||
| """ | ||
| header_name = "gray_region" | ||
| functional_type = "color" |
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.
functional_type = "grey_value" (UK spelling :D)
src/ethoscope/drawers/drawers.py
Outdated
|
|
||
| from ethoscope.utils.description import DescribedObject | ||
| import os | ||
| import numpy as np |
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.
remove if unneeded
src/ethoscope/core/roi.py
Outdated
| return out, self._mask | ||
| return out, self._mask | ||
|
|
||
| def find_region(self, x, y): |
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.
rename to find_sub_region
src/ethoscope/core/roi.py
Outdated
| :param orientation: Optional orientation Not implemented yet | ||
| :param regions: Optional sub-regions within the ROI. Not implemented yet | ||
| :param regions: Optional sub-regions within the ROI. | ||
| :type regions: :class:`~numpy.ndarray` |
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.
rename to subregions
qgeissmann
left a comment
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.
almost there!!!
src/ethoscope/core/roi.py
Outdated
| elif sub_rois.shape == self._mask.shape: | ||
| self._sub_rois = sub_rois | ||
| else: | ||
| self._sub_rois = self._mask |
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.
we can remove this line
src/ethoscope/core/roi.py
Outdated
| def find_sub_roi(self, x, y): | ||
| try: | ||
| grey_value = self._sub_rois[x, y] | ||
| except Exception, e: |
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.
except Exception as e:
src/ethoscope/core/variables.py
Outdated
| out += oy | ||
| return YPosVariable(out) | ||
|
|
||
| class SubRoiValueVariable(BaseIntVariable): |
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.
Make a new base class: BaseTinyIntVariable, and derive SubRoiValueVariable from it.
Also, verify that you can store a unsigned (8b)int inside. "TINYINT UNSIGNED" ? check that SQLite supports it (not only MySQL).
…abase, and a few name refactorings.
| _, oy = roi.offset | ||
| out += oy | ||
| return YPosVariable(out) | ||
|
|
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.
great, put these variables in your tracker class file ;)
| return [out] | ||
|
|
||
|
|
||
| class AdaptiveBGModelExtraObjectPosInfo(AdaptiveBGModel): |
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.
let's make another file for this one class
src/ethoscope/drawers/drawers.py
Outdated
| cv2.ellipse(img,((pos["x"],pos["y"]), (pos["w"],pos["h"]), pos["phi"]),colour,1, LINE_AA) | ||
|
|
||
|
|
||
| class SubRoiDrawer(BaseDrawer): |
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.
we should put your new drawer in another file ;)
…ecribe the subrois in which a fly stays in every frame. Also, the subroi drawer was put in a new file
…groundSubstractor, correction for find subroi
…groundSubstractor, correction for find subroi
No description provided.