-
Notifications
You must be signed in to change notification settings - Fork 10
Up to date #14
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
base: master
Are you sure you want to change the base?
Up to date #14
Conversation
godinlu
commented
Apr 16, 2025
- Simplified the file organization
- Added .gitignore rules for the notebooks
- Updated the tools file, as it was outdated
friedrichknuth
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.
Thank you so much for the PR @godinlu !! 🙌
I've added a few minor questions and comments below, which should be easily addressed/resolved before we merge this 💪
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.
Are these changes necessary for the new re-organization? I think it should still work like this, even after removing the sub-folder structure?
Import hipp.module seems cleaner than from . import module, but I'm not sure if one is better than the other.
In a more recent library I don't have the sub-folder structure and am importing the modules in the __init__.py with import gtsa.module for example.
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.
Both approaches work fine — the main difference is that import hipp.module uses an absolute import, while from . import module is a relative one. The relative form is a bit more robust in case the package name ever changes, since it doesn’t depend on the package being named hipp.
That said, I’m happy to switch to absolute imports if you prefer.
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.
OK makes sense and thank you for clarifying. I think it is OK to be explicit here about importing the modules from the library called hipp. My preference is to use import hipp.module.
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.
My preference also goes to absolut imports. Actually, in xdem we have a pre-commit linter called absolufy-imports.
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 think we can just ignore these globally and add an exception with something like:
**/raw_images/
**/fiducials/
**/preprocessed_images/
**/cropped_images/
**/qc/
!/examples/fiducial_proxy_detection/input_data/fiducials
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.
Good idea !
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.
What changed in this notebook? Is there a specific reason to update 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.
What changed in this notebook? Is there a specific reason to update 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.
Not really, I think i juste run it to be sure it work
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.
OK - thank you for verifying that the notebooks still run as expected. If there are no relevant changes in the notebooks, please just reset the files with git checkout -f path/to/file.ipynb.
hipp/batch.py
Outdated
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 assume you added this to check for some kind of error? Is there a better place or way to implement the check?
If not, print some kind of error message here that tells the user what is going on. Proper logging gets complicated, but here is an example of how I had been doing it thus far.
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.
My bad, I forgot to remove 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.
Nice! I see a number of changes here and they look like great improvements, but it is hard to exactly tell. I assume you tested this and it all works well? See additional comments and questions below.
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.
You right i will simplify it by simply open the img with cv2.imread(image_file_name, cv2.IMREAD_GRAYSCALE). And i will add the linear stretching.
hipp/tools.py
Outdated
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.
Is there an advantage to using tifffile? Why did you get rid of the linear stretching?
hipp/tools.py
Outdated
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.
The approach to convert RGB to grayscale isn't exactly correct, but I like the conversion to unit8. I assume that improves the performance of the interactive viewer?
hipp/tools.py
Outdated
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.
To convert RGB to grayscale, you want to use something like
weights = np.array([0.299, 0.587, 0.114])
image_gray = np.tensordot(image_array, weights, axes=([2], [0]))
assuming the image.shape = (height, width, bands) and the band order is Red, Green, Blue. These are the same weights as used by OpenCV
That said, the "color infrared" images have 3 bands that represent NIR, red, and green and I'm not sure what the "best" weights to convert those are. So just taking the same as used for RGB or simply the mean might be fine.
For now, I'd say use the weights above for any 3-band image, and mean for bands > 3 with a note in the doc string.
hipp/batch.py
Outdated
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.
What instance does this catch?
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.
It catch when fiducial_coordinates_true_mm is a numpy array because if you test a numpy array it will raise ValueError: The truth value of an array is ambiguous.
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.
OK - I think I hadn't run in to this because I provide fiducial_coordinates_true_mm as a list of tuples, not a numpy array in the example.
We could add an explicit check that it is some form of iterable with
from collections.abc import Iterable
if isinstance(fiducial_coordinates_true_mm, Iterable)
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 think is not None is more simple, and it's necessary because fiducial_coordinates_true_mm is converted in np.array here
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.
OK fine to leave it as is not None. I agree it is simpler!