-
Notifications
You must be signed in to change notification settings - Fork 111
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
solution to Issue 70 & new options #72
base: main
Are you sure you want to change the base?
Conversation
Hi @trasse, Thank you for the PR. Could you please refactor your code such that we can merge the bug fix and new options into |
yes, i just updated the request! |
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 additions! Thank you!
But we have to make sure that the old methods behave the same, else we will break running notebooks with the next release.
I think we should leave load_imgs_from_directory
as it is and add a new method load_imgs_from_directory2
which also returns the file-list. This will probably require an additional method load_imgs_from_file_list(files)
which loads the images from a file-list. This last method will then be called by both methods. Like this we can have both versions and avoid duplicated code.
@@ -10,7 +10,7 @@ class N2V_DataGenerator(): | |||
The 'N2V_DataGenerator' enables training and validation data generation for Noise2Void. | |||
""" | |||
|
|||
def load_imgs(self, files, dims='YX'): | |||
def load_imgs(self, files, to32bit, dims='YX'): |
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 parameter should have a default value of False
. This will ensure backwards compatibility.
@@ -80,7 +84,7 @@ def load_imgs(self, files, dims='YX'): | |||
|
|||
return imgs | |||
|
|||
def load_imgs_from_directory(self, directory, filter='*.tif', dims='YX'): | |||
def load_imgs_from_directory(self, directory, filter='*.tif', dims='YX', names_back = False, to32bit = True): |
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.
to32bit = False
for backwards compatibility.
""" | ||
|
||
files = glob(join(directory, filter)) | ||
files.sort() | ||
return self.load_imgs(files, dims=dims) | ||
if names_back: | ||
return files, self.load_imgs(files, to32bit, dims=dims) |
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 am not sure what the best practice would be here. Since this changes the return value of this method.
I think the best would be to refactor the code, such that we have two methods. The old one as it is and a new one which also returns the file list. Both these methods should probably wrap a new third method which takes a file-list and return the image-list.
I would also put the files
as second return parameter, then the user always gets the image-list as first return value.
print('Generated patches:', patches.shape) | ||
if shuffle_patches: | ||
np.random.shuffle(patches) | ||
#print('Generated patches:', patches.shape) |
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 is the reason to remove this print statement?
No description provided.