ExtensionsIndex icon indicating copy to clipboard operation
ExtensionsIndex copied to clipboard

Add SlicerBrainParcellation275 extension

Open ErenArkun opened this issue 1 year ago • 4 comments

New extension

  • [x] Extension has a reasonable name (not too general, not too narrow, suggests what the extension is for)
  • [x] Repository name is Slicer+ExtensionName
  • [x] Repository is associated with 3d-slicer-extension GitHub topic so that it is listed here. To edit topics, click the settings icon in the right side of "About" section header and enter 3d-slicer-extension in "Topics" and click "Save changes". To learn more about topics, read https://help.github.com/en/articles/about-topics
  • [x] Extension description summarizes in 1-2 sentences what the extension is usable (should be understandable for non-experts)
  • [x] Any known related patents must be mentioned in the extension description.
  • [x] LICENSE.txt is present in the repository root. MIT (https://choosealicense.com/licenses/mit/) or Apache (https://choosealicense.com/licenses/apache-2.0/) license is recommended. If source code license is more restrictive for users than MIT, BSD, Apache, or 3D Slicer license then the name of the used license must be mentioned in the extension description.
  • [x] Extension URL and revision (scmurl, scmrevision) is correct, consider using a branch name (main, release, ...) instead of a specific git hash to avoid re-submitting pull request whenever the extension is updated
  • [x] Extension icon URL is correct (do not use the icon's webpage but the raw data download URL that you get from the download button - it should look something like this: https://raw.githubusercontent.com/user/repo/main/SomeIcon.png)
  • [x] Screenshot URLs (screenshoturls) are correct, contains at least one
  • [x] Homepage URL points to valid webpage containing the following:
    • [x] Extension name
    • [x] Short description: 1-2 sentences, which summarizes what the extension is usable for
    • [x] At least one nice, informative image, that illustrates what the extension can do. It may be a screenshot.
    • [x] Description of contained modules: at one sentence for each module
    • [x] Tutorial: step-by-step description of at least the most typical use case, include a few screenshots, provide download links to sample input data set
    • [x] Publication: link to publication and/or to PubMed reference (if available)
    • [x] License: We suggest you use a permissive license that includes patent and contribution clauses. This will help protect developers and ensure the code remains freely available. We suggest you use the Slicer License or the Apache 2.0. Always mention in your README file the license you have chosen. If you choose a different license, explain why to the extension maintainers. Depending on the license we may not be able to host your work. Read here to learn more about licenses.
    • [x] Content of submitted json file is consistent with the top-level CMakeLists.txt file in the repository (dependencies, etc. are the same)
  • Hide unused features in the repository to reduce noise/irrelevant information:
    • [x] Click Settings and in repository settings uncheck Wiki, Projects, and Discussions (if they are currently not used)
    • [x] Click the settings icon next to About in the top-right corner of the repository main page and uncheck Releases and Packages (if they are currently not used)

ErenArkun avatar Nov 14 '24 12:11 ErenArkun

This will be great, thank you for your contribution!

I've tried to use your module but it failed to load, with this error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\andra\AppData\Local\slicer.org\Slicer 5.7.0-2024-11-01\lib\Python\Lib\imp.py", line 169, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 613, in _exec
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:/D/SlicerBrainParcellation275/slicer-brain-parcellation275/BrainSegmentation.py", line 3, in <module>
    import nibabel as nib
ModuleNotFoundError: No module named 'nibabel'
[Qt] loadSourceAsModule - Failed to load file "C:/D/SlicerBrainParcellation275/slicer-brain-parcellation275/BrainSegmentation.py"  as module "BrainSegmentation" !
[Qt] Fail to instantiate module  "BrainSegmentation"
[Python] The module factory manager reported an error. One or more of the requested module(s) and/or dependencies thereof may not have been loaded.

The issue is that in the module .py file (BrainSegmentation.py) you can only import Python modules at the file level that are built-in Python modules or they are in packages that are bundled with Slicer. In your Slicer module you can install any packages that you need later, and then import them inside functions or in Python modules (for example, in your utils subfolder).

Specifically, these imports needs to go:

import nibabel as nib
from nibabel import processing
import torch
from tqdm import tqdm as std_tqdm

Since many extensions use pytorch, it is a huge package, and its installation is not trivial, it has to be installed via the SlicerPytorch extension. See a complete example here: https://github.com/lassoan/SlicerTotalSegmentator/blob/c4144875e600705f4c4b30a44b49d05d27ffb757/TotalSegmentator/TotalSegmentator.py#L757-L776

A few more small comments:

  • Remove temporary __pycache__ folders from the git repository
  • Some of the files in https://github.com/ErenArkun/SlicerBrainParcellation275/tree/main/slicer-brain-parcellation275/level folder might be redundant. You may be able to store complex data structures in a .json file that you can load into Python by a single command and then you don't .

lassoan avatar Nov 16 '24 03:11 lassoan

Thank you for your feedback. I will look into the issue you encountered.

ErenArkun avatar Nov 26 '24 18:11 ErenArkun

Let us know if you have completed your revisions and your extension is ready for review.

lassoan avatar Dec 02 '24 21:12 lassoan

Some automatic validation checks failed. They need to be fixed before the extension can be added to the Extensions Index.

lassoan avatar Sep 07 '25 02:09 lassoan