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

Misc features #36

Merged
merged 11 commits into from
Oct 5, 2023
Merged

Misc features #36

merged 11 commits into from
Oct 5, 2023

Conversation

LorenzLamm
Copy link
Collaborator

Hi,

I have implemented a couple of potentially useful features from some user requests, and packed it together with some small bug fixes and documentation:

  1. Adjustable thresholding: It's now possible to set a different threshold for the scoremap during inference (instead of default 0.0)
  2. Related to this: I added the functionality "membrain thresholds" that takes as input a scoremap and applied the given thresholds to it
  3. optional deactivation of test time augmentation: It is now possible to deactivate test time augmentation. Test time augmentation helps a bit with the segmentation performance, but also increases computation 8-fold. I guess it can be useful for larger datasets to deactivate it
  4. documentation for the above functionalities
  5. fixed some typos in the documentation

I think most things should be relatively straightforward, but feel free take a look and let me know if you spot anything :)

@@ -193,7 +193,7 @@ def extract_patches(
min_coords[0] : min_coords[0] + 160,
min_coords[1] : min_coords[1] + 160,
min_coords[2] : min_coords[2] + 160,
]
].copy()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When not adding the "copy", overlapping extracted patches will have the ignore-label padding in each other, because the original array is padded instead of the small patches.

@@ -121,7 +128,7 @@ def convert_single_nrrd_files(labels_dir, corrections_dir, out_dir):
merged_corrections = get_corrections_from_folder(
cur_patch_corrections_folder, os.path.join(labels_dir, label_file)
)
out_file = os.path.join(out_dir, label_file)
out_file = os.path.join(out_dir, token + ".nii.gz")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If not specifying .nii.gz format, it will take to data format of the inputs (which can also be e.g. .mrc)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I follow. It looks like the output file path is hardcoded to .nii.gz.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly. I hard-coded it to nii.gz s.t. it does not save out e.g. .mrc files. The input to the training is still nii.gz. We may want to change that at some point to something more common in Cryo-ET. This change here is to make everything compatible with the current training setup.

@@ -95,3 +109,53 @@ def components(
os.path.splitext(os.path.basename(segmentation_path))[0] + "_components.mrc",
)
store_tomogram(filename=out_file, tomogram=segmentation)


@cli.command(name="thresholds", no_args_is_help=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a separate command for a function that

  1. takes as input a scoremap produced by MemBrain-seg, together with multiple float values
  2. thresholds the scoremap at each given float value and stores the resulting segmentation mask

Copy link
Collaborator

@kevinyamauchi kevinyamauchi left a comment

Choose a reason for hiding this comment

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

This LGTM! I just have a small minor question below. Please feel free to merge once you've addressed it.

@@ -121,7 +128,7 @@ def convert_single_nrrd_files(labels_dir, corrections_dir, out_dir):
merged_corrections = get_corrections_from_folder(
cur_patch_corrections_folder, os.path.join(labels_dir, label_file)
)
out_file = os.path.join(out_dir, label_file)
out_file = os.path.join(out_dir, token + ".nii.gz")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I follow. It looks like the output file path is hardcoded to .nii.gz.

@LorenzLamm LorenzLamm merged commit c132a79 into main Oct 5, 2023
11 checks passed
@LorenzLamm LorenzLamm deleted the misc_features branch October 5, 2023 08:46
@LorenzLamm LorenzLamm mentioned this pull request Oct 5, 2023
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