Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LION: Born from MOOSE 2.0 lineage, this king excels in PET tumor segmentation. Harnessing 1014 Autopet datasets, it offers unparalleled precision in lesion detection. Tailor workflows, integrate seamlessly, and experience next-gen tech today!

Notifications You must be signed in to change notification settings

salimkanoun/LION

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lion-logo.png

LION (Lesion segmentatION): Loud. Proud. Unbounded. 🦁

Recommended Version Monthly Downloads Daily Downloads DOI All Contributors

LION has roared onto the scene, revolutionizing the way we view lesion segmentation. Born from the same lineage as MOOSE 3.0, LION is laser-focused on tumor segmentation. Our curated models, each crafted with precision, cater to various tracers, setting the gold standard in lesion detection.

✨ Exclusive Engineering Paradigm: With LION, segmentation is not just a task; it's an orchestrated dance of models. Define workflows for each model, mix and match channels as some models thrive on PET/CT while others are optimized for just PET or CT. Run them in a sequence that maximizes output and efficiency. This unique trait of LION lets you tailor the process to your exact needs, making lesion segmentation an art of precision.

πŸ”” Flexibility Unleashed: Whether you're looking for a command-line tool for batch processing or a library package for your Python projects, LION has you covered. Seamlessly integrate it into your work environment and watch it shine.

Dive into the exciting world of PET tumor segmentation with LION and experience the future today!

πŸ”” Important Notification: As of now, the LION tool is optimized and validated for FDG imaging. Development for PSMA imaging is ongoing and will be available soon. We appreciate your patience and understanding. Stay tuned for updates! πŸ””


Requirements βœ…

For an optimal experience with LION, ensure the following:

  • Operating System: LION runs smoothly on Windows, Mac, or Linux.
  • Memory: At least 32GB of RAM ensures LION operates without a hitch.
  • GPU: For blazing-fast results, an NVIDIA GPU comes highly recommended. But if you don't have one, fret not! LION will still get the job done, just at a more leisurely pace.
  • Python: Version 3.9.2 or above. We like to stay updated!

Installation Guide πŸ› οΈ

Navigating the installation process is a breeze. Just follow the steps below:

For Linux and MacOS 🐧🍏

  1. Create a Python environment, for example, 'lion-env'.
python3 -m venv lion-env
  1. Activate your environment.
source lion-env/bin/activate  # for Linux
source lion-env/bin/activate  # for MacOS
  1. Install LION.
pip install lionz

For Windows πŸͺŸ

  1. Set up a Python environment, say 'lion-env'.
python -m venv lion-env
  1. Get your environment up and running.
.\lion-env\Scripts\activate
  1. Hop over to the PyTorch website and fetch the right version for your system. This step is crucial!
  2. Finish up by installing LION.
pip install lionz

Usage Guide πŸ“š

Command-line Tool for Batch Processing πŸ’»

Starting with LION is as intuitive as it gets. Here's how:

lionz -d <path_to_image_dir> -m <model_name>

Replace <path_to_image_dir> with your image directory and <model_name> with your chosen segmentation model's name.

Real-Life Usage Example 🌟

To run LION using the 'fdg' model on a batch of images located in /path/to/dummy/image/directory, you'd simply execute:

lionz -d /path/to/dummy/image/directory -m fdg

Thresholding Feature βœ‚οΈ

LION is also equipped with a thresholding feature to refine your segmentations. Just add -t and the value you want to use for thresholding.

Important: Thresholding is only supported with DICOM or SUV NIfTI inputs! If you don't require thresholding, feel free to use any LION-compliant input.

Here's how you can apply thresholding for SUV 2.5:

lionz -d /path/to/dummy/image/directory -m fdg -t 2.5

Generating a MIP with overalayed segmentation

If you want to have a quick glance at the segmentation by having a rotation MIP with the obtained segmentations overlayed all you need is to add the -gen-mip flag to your command.

Here's how you can apply thresholding for SUV 2.5:

lionz -d /path/to/dummy/image/directory -m fdg -gen-mip

And, if you ever find yourself needing some guidance:

lionz -h

This trusty command will spill all the beans about available models and their specialties.

Using LION as a Library πŸ“¦πŸ

LION isn't just a command-line powerhouse; it’s also a flexible library for Python projects. Here’s how to make the most of it:

First, import the lion function from the lionz package in your Python script:

from lionz import lion

Calling the lion Function 🦌

The lion function is versatile and accepts various input types. It takes five main arguments:

  1. input: The data to process, which can be:
    • A path to an input file or directory (NIfTI, either .nii or .nii.gz).
    • A tuple containing a NumPy array and its spacing (e.g., numpy_array, (spacing_x, spacing_y, spacing_z)).
    • A SimpleITK image object.
  2. model_name: The model name to use for segmentation.
  3. output_dir: The directory where the results will be saved.
  4. accelerator: The type of accelerator to use ("cpu", "cuda", or "mps" for Mac).
  5. threshold: The value to use for thresholding. Optional

Examples πŸ“‚βœ‚οΈπŸ’»

Here are some examples to illustrate different ways to use the lion function:

  1. Using a file path and multiple models:

    lion('/path/to/input/file', 'fdg', '/path/to/save/output', 'cuda', 2.5)
  2. Using a NumPy array with spacing:

    lion((numpy_array, (1.5, 1.5, 1.5)), 'psma', '/path/to/save/output', 'cuda', 2.5)
  3. Using a SimpleITK image:

    lion(simple_itk_image, 'fdg', '/path/to/save/output', 'cuda', 2.5)

Usage of lion() in your code

To use the lion() function, ensure that you wrap the function call within a main guard to prevent recursive process creation errors:

from lionz import lion

if __name__ == '__main__':
    input_file = '/path/to/input/file'
    model = 'fdg'
    output_directory = '/path/to/save/output'
    accelerator = 'cuda'
    threshold = 2.5
    lion(input_file, models, output_directory, accelerator, threshold)

Directory Conventions for LION πŸ“‚πŸ·οΈ

For batch mode users ⚠️, ensure your data structure and naming conventions align with the provided guidelines. LION is compatible with both DICOM and NIFTI formats. For DICOM, LION discerns the modality from tags. For NIFTI, file naming is key. Allowed modality tags: PT for PET, CT for CT as of now.

Directory Structure 🌳

Organize your dataset as follows:

πŸ“‚ LION_data/
β”‚
β”œβ”€β”€ πŸ“ Subject1
β”‚   β”œβ”€β”€ πŸ“ Modality1
β”‚   β”‚   └── πŸ“„ File1.dcm
β”‚   └── πŸ“ Modality2
β”‚       └── πŸ“„ File2.dcm
β”œβ”€β”€ πŸ“ Subject2
β”‚   └── πŸ“„ Modality1_Subject2.nii
β”‚   └── πŸ“„ Modality2_Subject2.nii
└── πŸ“ Subject3
    └── πŸ“„ Modality1_Subject3.nii
    └── πŸ“„ Modality2_Subject3.nii

Naming Conventions for NIFTI πŸ“

Ensure you attach the correct modality as a prefix in the file name.


Dataset Organization for FDG Model

For the FDG model, your dataset must be organized strictly according to the guidelines below, considering PT (Positron Emission Tomography) and CT (Computed Tomography) as the primary modalities:

πŸ“‚ FDG_data/
β”‚
β”œβ”€β”€ πŸ“ Patient1
β”‚   └── πŸ“ AnyFolderNameForPT
β”‚       β”œβ”€β”€ πŸ“„ DICOM_File1.dcm
β”‚       β”œβ”€β”€ πŸ“„ DICOM_File2.dcm
β”‚       └── ...
β”œβ”€β”€ πŸ“ Patient2
β”‚   └── πŸ“„ PT_Patient2.nii
└── πŸ“ Patient3
    └── πŸ“„ PT_Patient3.nii.gz

Important Guidelines:

  • Each patient's data must be stored in a dedicated folder.

  • For DICOM format:

    • Patient1's example demonstrates the DICOM structure. Inside each patient's main folder, the inner folders can have any name for PT modality. Multiple DICOM files can be stored in these folders. The modality (PT) will be inferred from the DICOM's modality tag.
  • For NIFTI format:

    • Patient2 and Patient3 examples demonstrate the NIFTI structure. For these, PT modality is directly within the patient's folder with the .nii extension. Adjust the naming structure as per the specifics of your dataset if required.
  • Only DICOM and NIFTI formats are supported. No other imaging formats are allowed.

  • Adhering to these guidelines is non-negotiable for both FDG and PSMA models.


πŸ“ LIONz Output Folder Structure for FDG Model

When you run the FDG model, an output folder named lionz-fdg-<timestamp> will be generated in the respective subject directory. Here's a breakdown of the folder structure:

πŸ“‚ lionz-fdg-2023-09-18-10-07-25/
β”‚
β”‚
β”œβ”€β”€ πŸ“‚ PT
β”‚   └── πŸ“„ PT_0147.nii.gz
β”‚
β”œβ”€β”€ πŸ“‚ segmentations
β”‚   β”œβ”€β”€ πŸ“„ 0147_no_tumor_seg.nii.gz
β”‚   └── πŸ“½ 0147_rotational_mip.gif (optional)
β”‚
└── πŸ“‚ stats
    └── πŸ“„ 0147_metrics.csv

πŸ“Œ Breakdown:

  • πŸ“‚ segmentations: Houses all segmentation-related files.
    • πŸ“„ NIFTI files showing segmentations.
    • πŸ“½ GIF files representing various views. Only when requested by the user.
  • πŸ“‚ stats: Contains .csv files with metrics related to the analysis.

Harness the power of LION and elevate your PET tumor segmentation game! πŸš€πŸ¦

Remember, the LION team is here to support you every step of the way. Should you need any assistance or if you'd like to provide feedback, don't hesitate to reach out to our dedicated support team in discord.

With LION by your side, your lesion segmentation adventures will be unstoppable! 😺🌟

Dive in now and make PET tumor segmentation a seamless experience!


Thank you for trusting LION with your PET tumor segmentation needs. We're committed to providing you with top-notch tools and services that make your work easier and more efficient.


A Note on QIMP Python Packages: The 'Z' Factor πŸ“šπŸš€

Every Python package at QIMP carries a unique mark – a distinctive 'Z' at the end of their names. This isn't just a quirk or a random choice. The 'Z' is emblematic, an insignia of our forward-leaning vision and unwavering dedication to continuous innovation.

Take, for instance, our LION package, dubbed 'lionz', pronounced "lion-zee". Now, one might wonder, why append a 'Z'?

In the expansive realm of science and mathematics, 'Z' is frequently invoked as a representation of the unexplored, the variables that are shrouded in mystery, or the ultimate point in a sequence. This mirrors our ethos at QIMP perfectly. We're inveterate boundary-pushers, ever eager to trek into the uncharted, always aligning ourselves with the vanguard of technological advancement. The 'Z' is a testament to this ethos. It symbolizes our ceaseless endeavor to transcend the conventional, to journey into the untouched, and to be the torchbearers of the future in medical imaging.

So, the next time you stumble upon a 'Z' in any of our package names, let it serve as a reminder of the zest for exploration and the spirit of discovery that fuels us. With QIMP, you're not merely downloading a tool; you're aligning yourself with a movement that aims to redefine the landscape of medical image processing. Let's soar into the realms of the 'Z' dimension, side by side! πŸš€


Contributors ✨

Thanks goes to these wonderful people (emoji key):

Lalith Kumar Shiyam Sundar
Lalith Kumar Shiyam Sundar

πŸ’»
Manuel Pires
Manuel Pires

πŸ’»
Sebastian Gutschmayer
Sebastian Gutschmayer

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

About

LION: Born from MOOSE 2.0 lineage, this king excels in PET tumor segmentation. Harnessing 1014 Autopet datasets, it offers unparalleled precision in lesion detection. Tailor workflows, integrate seamlessly, and experience next-gen tech today!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •