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! |
tibuch
left a comment
There was a problem hiding this comment.
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.
| """ | ||
|
|
||
| def load_imgs(self, files, dims='YX'): | ||
| def load_imgs(self, files, to32bit, dims='YX'): |
There was a problem hiding this comment.
This parameter should have a default value of False. This will ensure backwards compatibility.
| 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.
to32bit = False for backwards compatibility.
| 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.
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.
What is the reason to remove this print statement?
No description provided.