diff --git a/CHANGELOG.md b/CHANGELOG.md index edce4f8..8845fc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [v2.2.4_gpu] - 2025-11-20 +### Added security +- added documentation with a first-page documentation in MELD Patient Report +- added security layer with a meld license needed to run the tool +- separate gpu/cpu version of MELD Graph (this is the GPU version) + +## [v2.2.4] - 2025-11-20 +### Added security +- added documentation with a first-page documentation in MELD Patient Report +- added security layer with a meld license needed to run the tool +- separate gpu/cpu version of MELD Graph (this is the CPU version) + ## [v2.2.3] - 2025-10-20 ### Fixed diff --git a/Dockerfile b/Dockerfile index d37ee2e..69e8c3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ COPY ./environment.yml ./environment.yml # Create the meld_graph environment RUN micromamba create -y -f environment.yml \ - && micromamba clean -afy + && micromamba clean --all --yes # meld graph stage @@ -25,10 +25,10 @@ FROM debian:12-slim AS MELDgraph RUN mkdir -p /opt/freesurfer-7.2.0 #Update ubuntu. -RUN apt-get -y update && apt-get install --no-install-recommends -y wget && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN apt-get -y update && apt-get install --no-install-recommends -y wget aria2 ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Download freesurfer -RUN wget -N -O freesurfer-linux-ubuntu18_amd64-7.2.0.tar.gz --no-check-certificate --progress=bar:force https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.2.0/freesurfer-linux-ubuntu18_amd64-7.2.0.tar.gz && \ +RUN aria2c -x 16 -s 16 -k 1M --check-certificate=false -c https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.2.0/freesurfer-linux-ubuntu18_amd64-7.2.0.tar.gz && \ tar -xzf freesurfer-linux-ubuntu18_amd64-7.2.0.tar.gz -C /opt/freesurfer-7.2.0 --owner root --group root --no-same-owner --strip-components 1 --keep-newer-files \ --exclude='average/mult-comp-cor' \ --exclude='lib/cuda' \ @@ -98,8 +98,8 @@ COPY . . ENV MAMBA_ROOT_PREFIX="/opt/conda" ENV MAMBA_EXE="/bin/micromamba" -# The core change: Use a CUDA-enabled PyTorch version and install dependencies in the correct order. -RUN micromamba run -n meld_graph /bin/bash -c "pip install --no-cache-dir torch==1.10.0+cu113 torchvision==0.11.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html && pip install -e . && pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu111.html && pip install torch-geometric==2.4.0" \ +# The core change: install dependencies in the correct order. +RUN micromamba run -n meld_graph /bin/bash -c "pip install --no-cache-dir torch==1.10.0 torchvision==0.11.1 && pip install -e . && pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0.html && pip install torch-geometric==2.4.0 && pip install captum==0.6.0" \ && micromamba shell init -s bash \ && echo "micromamba activate meld_graph" >> $HOME/.bashrc diff --git a/MELD_logo.png b/MELD_logo.png deleted file mode 100644 index a71e815..0000000 Binary files a/MELD_logo.png and /dev/null differ diff --git a/README.md b/README.md index 4a99c97..2208e6d 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,13 @@ This package is a pipeline to segment FCD-lesions from MRI scans. ## UPDATE -**SIGN UP TO THE MELD GRAPH MAILING LIST**: -We request that all MELD Graph users sign up to the mailing list. If you are using MELD Graph, please send an email to `meld.study@gmail.com` with the subject 'Request to be added to the MELD Graph mailing list' and provide use with your name and institute. This will ensure that we can update you about bug fixs and new releases. +**REGISTER TO GET YOUR MELD LICENSE**: +We request that all MELD graph users fill the [MELD Graph registration form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). Following registration you will received a license file. This file will be needed for use of all future MELD Graph versions v2.2.4 and above. Your email address will be added to the MELD Graph mailing list. This will ensure that we can update you about bugs fix and new releases. -**IF YOU ARE STILL RUNNING WITH V2.2.1 - PLEASE UPDATE TO VERSION V2.2.2**: -We have released MELD Graph V2.2.2 which fixes a couple of issues found by users. For more information about the release please see [MELD Graph V2.2.2](https://github.com/MELDProject/meld_graph/releases/tag/v2.2.2). To update your code please follow the guidelines [Updating MELD Graph to V2.2.2](https://meld-graph.readthedocs.io/en/latest/FAQs.html#Updating-MELD-Graph-to-V2.2.2) from our FAQ. +**PLEASE UPDATE TO V2.2.4**: +We have released MELD Graph v2.2.4 and v2.2.4_gpu, the new stable versions of MELD Graph with increased level of security and documentation. All current users are required to update to v2.2.4. Older versions will be deprecated and not supported. +If you have GPU ressources with at least 20GB of VRAM and would like to use GPU for Fastsurfer segmentation and accelerated MELD Graph prediction, please install v2.2.4_gpu. To update your code please follow the guidelines [Updating MELD Graph version](https://meld-graph.readthedocs.io/en/latest/FAQs.html#Updating-MELD-Graph-version) from our FAQ. -**NEW RELEASE V2.2.3 IN TEST - FOR GPU USERS**: -We have released MELD Graph v2.2.3 which enable to use the Docker with GPU. If you already have MELD Graph V2.2.2 and do not need to use the GPU ressources, we recommand to keep your current version. If you want to use the GPU please update your code to get the latest MELD Graph v2.2.3 docker. ![overview](https://raw.githubusercontent.com//MELDProject/meld_graph/main/docs/images/Fig1_pipeline.jpg) diff --git a/compose.yml b/compose.yml index 31ccdbb..8cfe4e9 100644 --- a/compose.yml +++ b/compose.yml @@ -6,8 +6,10 @@ services: - ./docker-data:/data environment: - FS_LICENSE=/run/secrets/license.txt + - MELD_LICENSE=/run/secrets/meld_license.txt secrets: - license.txt + - meld_license.txt user: $DOCKER_USER deploy: resources: @@ -19,3 +21,5 @@ services: secrets: license.txt: file: ./license.txt + meld_license.txt: + file: ./meld_license.txt diff --git a/docs/FAQs.md b/docs/FAQs.md index 447c76f..c67ae63 100644 --- a/docs/FAQs.md +++ b/docs/FAQs.md @@ -2,6 +2,39 @@ ## **Issues & questions with installation** +### **Issue with the MELD License** + +- If your issue is: + ```bash + ERROR: Could not find a MELD_LICENSE environment variable. Please ensure you have exported the MELD_LICENSE environment following the MELD Graph installation guidelines + ``` + This means that the MELD_LICENSE variable has not been exported/initialised in the environment (terminal) you are using. The variable should be automatically exported when using compose.yml file for the Docker, or meldgraph.sh for the native installation. You can export manually the environment variable by doing: + ```bash + export MELD_LICENSE= + ``` + Please contact the team if the issue continues + +- If your issue is: + ```bash + ERROR: The file meld_license.txt does not exist. + Please ensure you got the meld license file by filling the registration form provided in the MELD Graph installation guidelines and provided the right path to the file + ``` + This means that the meld_license.txt cannot be found in the main meld graph folder (where the code is). This can happen if you did not get the MELD license file or if the file was placed in an incorect folder. To get the proper MELD license ID, please fill in to the [MELD registration form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). + +- If your issue is: + ```bash + ERROR: The license ID provided does not seem correct. + Please ensure you got the correct meld license file by filling the registration form provided in the MELD Graph installation guidelines and provided the right path to the file + ``` + or + ```bash + ERROR: The license file meld_license.txt does not seem correct. + Please ensure you got the correct meld license file by filling the registration form provided in the MELD Graph installation guidelines and provided the right path to the file + + ``` + This means that the MELD license file exists and is at the correct place, but the license ID does not exist or is incorrect. This can happen if you have used the Freesurfer license instead of the MELD license file, or if you have a fake MELD license file. To get the proper MELD license ID, please fill in the [MELD registration form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). + + ### **Issue with Native installation MAC Intel user - Issue when running meldsetup.sh** If you are a MAC user with an intel processor you will run into the issue below when running the command ```./meldsetup.sh```: @@ -130,9 +163,9 @@ If it is another pathology e.g. a tumour, the pipeline has not been developed / --- -## **Updating MELD Graph to V2.2.2** +## **Updating MELD Graph version** -The instructions below are for users that already have used MELD Graph v2.2.1 on patients and would like to update to MELD Graph V2.2.2 while keeping the same meld_data folder. +The instructions below are for users that already have used a version of MELD Graph (e.g. v2.2.1) on patients and would like to update to the latest version of MELD Graph (e.g. v2.2.4) while keeping the same meld_data folder. ### 📥 **Get the updated code** @@ -142,9 +175,9 @@ Please follow the Download method below to get the new code ::::{tab-set} :::{tab-item} Download -1. Go to the [github releases page](https://github.com/MELDProject/meld_graph/releases) and download the latest version `V2.2.2`, by clicking on `Source code (zip)` or `Source code (tar.gz)`. -2. Extract the folder `meld_graph-2.2.2` -3. Copy the files below from your old `meld_graph-2.2.1` directory to your new `meld_graph-2.2.2` directory: +1. Go to the [github releases page](https://github.com/MELDProject/meld_graph/releases) and download the latest version V2.2.X (e.g. `V2.2.4`), by clicking on `Source code (zip)` or `Source code (tar.gz)`. +2. Extract the folder `meld_graph-2.2.X` +3. Copy the files below from your old `meld_graph-2.2.X` directory to your new `meld_graph-2.2.X` directory: - the freesurfer `license.txt` - the `compose.yml` - the `meld_config.ini` @@ -160,8 +193,9 @@ git stash pop ``` ::: :::: +4. If not already done, register to MELD Graph to get your MELD License by filling the [form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). -Then depending on if you have a Native, Docker or Singularity installation of MELD Graph `v2.2.1` you will need to follow the same type of installation to update to `v2.2.2`: +Then depending on if you have a Native, Docker or Singularity installation of the previous MELD Graph version you will need to follow the same type of installation to update to the latest version: ::::{tab-set} @@ -173,7 +207,7 @@ Then depending on if you have a Native, Docker or Singularity installation of ME ``` conda activate meld_graph ``` -2. Update the code package in the environment. Make sure you are in the new `meld_graph-2.2.2` directory and run: +2. Update the code package in the environment. Make sure you are in the new `meld_graph-2.2.X` directory and run: ``` pip install -e . ``` @@ -200,7 +234,10 @@ singularity pull docker://meldproject/meld_graph:latest ::: :::: -### 🗂️ **Update your meld_data_folder with the new test data** +### 🗂️ **For v2.2.1 users: Update your meld_data_folder with the new test data** + +If you are working with v2.2.1 and want to update to a version above, you will need to download the test data again. If you have a version v2.2.2 or above, you can skip this step. + The command below will only download the test data and it should not overwrite the patients you have already ran. **WARNING**: It will overwrite the `demographics_file.csv` and `list_subjects.txt`. Please ensure to keep a copy of those files if you have modified them. @@ -242,10 +279,13 @@ Follow the guidelines **"Verify installation"** to run the test again. - 🚀[Singularity Users](https://meld-graph.readthedocs.io/en/latest/install_singularity.html#verify-installation) -### 🧠 **Update your predictions with the registration fix** +### 🧠 **For v2.2.1 only: Update your predictions with the registration fix** + +If you are working with v2.2.1 and want to update to a version above, you will need to download the test data again. If you have a version v2.2.2 or above, you can skip this step. + If you want to update the predictions with the new registration for patients you have already ran through MELD Graph, please follow the instructions bellow: -1) Create a list of ids of patients you want to rerun: e.g. `list_subjects_rerun_v2.2.2.txt` +1) Create a list of ids of patients you want to rerun: e.g. `list_subjects_rerun_v2.2.X.txt` 2) Then run one of the commands below. It will use the predictions already existing for your patient. @@ -258,7 +298,7 @@ If you want to update the predictions with the new registration for patients you **💻 Native Installation Users:** ```bash -./meldgraph.sh run_script_prediction.py -ids list_subjects_rerun_v2.2.2.txt --skip_prediction +./meldgraph.sh run_script_prediction.py -ids list_subjects_rerun_v2.2.X.txt --skip_prediction ``` ::: @@ -267,7 +307,7 @@ If you want to update the predictions with the new registration for patients you **🐳 Docker Users:** ```bash -DOCKER_USER="$(id -u):$(id -g)" docker compose run meld_graph python scripts/new_patient_pipeline/run_script_prediction.py -ids list_subjects_rerun_v2.2.2.txt --skip_prediction +DOCKER_USER="$(id -u):$(id -g)" docker compose run meld_graph python scripts/new_patient_pipeline/run_script_prediction.py -ids list_subjects_rerun_v2.2.X.txt --skip_prediction ``` ::: @@ -276,7 +316,7 @@ DOCKER_USER="$(id -u):$(id -g)" docker compose run meld_graph python scripts/new **🚀 Singularity Users:** ```bash -singularity exec meld_graph.sif /bin/bash -c "cd /app && python scripts/new_patient_pipeline/run_script_prediction.py -ids list_subjects_rerun_v2.2.2.txt --skip_prediction" +singularity exec meld_graph.sif /bin/bash -c "cd /app && python scripts/new_patient_pipeline/run_script_prediction.py -ids list_subjects_rerun_v2.2.X.txt --skip_prediction" ``` ::: -:::: +:::: \ No newline at end of file diff --git a/docs/images/1st_page_report.jpg b/docs/images/1st_page_report.jpg new file mode 100644 index 0000000..5e4b12f Binary files /dev/null and b/docs/images/1st_page_report.jpg differ diff --git a/docs/install_docker.md b/docs/install_docker.md index a80fe7d..bbe738b 100644 --- a/docs/install_docker.md +++ b/docs/install_docker.md @@ -6,8 +6,8 @@ The Docker container has all the prerequisites embedded on it which makes it eas Notes: - Currently only tested on **Linux**. HPC users should use the [Singularity version](https://meld-graph.readthedocs.io/en/latest/install_singularity.html). Mac M chip computers have to do a [install_native](https://meld-graph.readthedocs.io/en/latest/install_native.html) -- You will need **~20GB of space** to install the container -- The docker image contains Miniconda 3, Freesurfer V7.2, Fastsurfer V1.1.2 and torch 1.10.0+cu113. The whole image is 20 GB. +- You will need **~13GB of space** to install the container +- The docker image contains Miniconda 3, Freesurfer V7.2, Fastsurfer V1.1.2 and torch 1.10.0. The whole image is ~13 GB. - The predictions stage can use over **20GB of RAM/VRAM**, therefore we recommend using a computer of **at least 24GB of RAM (for CPU) or VRAM (for GPU)**. Here is the video tutorial detailing how to install the Docker - [Docker Installation](https://youtu.be/oduOe6NDXLA). @@ -28,9 +28,9 @@ On windows, Docker should be [using WSL2](https://docs.docker.com/desktop/wsl/). ::: -## Enable GPUs +## Enable GPUs (compatible with MELD Graph GPU version only ) -Enabling your computer's GPUs for running the pipeline accelerates the brain segmentation when using Fastsurfer and the predictions. Follow instructions for your operating system to install. +Enabling your computer's GPUs for running the pipeline accelerates the brain segmentation when using Fastsurfer and the predictions. Ensure you have installed a MELD Graph version compatible with GPU (see [release versions](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header)). Follow instructions for your operating system to install. ::::{tab-set} @@ -49,13 +49,17 @@ Follow the instructions for [*enabling NVIDIA CUDA on WSL*](https://learn.micros ## Freesurfer licence You will need to download a Freesurfer license.txt to enable Freesurfer/Fastsurfer to perform the segmentation. Please follow the [guidelines](https://surfer.nmr.mgh.harvard.edu/fswiki/License) to download the file and keep a record of the path where you saved it. +## MELD license +In order to run MELD Graph you need to have a `meld_license.txt` in the meld graph folder. To get this file, please fill out the [MELD registration form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). Once submitted, your application will be automatically reviewed and the meld_license.txt file will be send to your email. + ## Configuration In order to run the docker, you'll need to configure a couple of files 1. Download `meld_graph_X.X.X.zip` with X.X.X the version from the [latest github release](https://github.com/MELDProject/meld_graph/releases/latest) and extract it. -2. Copy the freesurfer `license.txt` into the extracted folder -3. Create the meld_data folder, if it doesn't exist already. This folder is where you would like to store MRI data to run the classifier -4. In the `meld_graph_X.X.X` extracted folder open and edit the compose.yml to add the path to the meld_data folder. The initial compose.yml file looks like :: +2. Copy the freesurfer `license.txt` into the extracted folder (see above how to get the Freesurfer license) +3. Copy the MELD `meld_license.txt` into the extracted folder (see above how to get the MELD license) +4. Create the meld_data folder, if it doesn't exist already. This folder is where you would like to store MRI data to run the classifier +5. In the `meld_graph_X.X.X` extracted folder open and edit the compose.yml to add the path to the meld_data folder. The initial compose.yml file looks like :: ``` services: meld_graph: diff --git a/docs/install_native.md b/docs/install_native.md index 0b0ac0e..6a8799a 100644 --- a/docs/install_native.md +++ b/docs/install_native.md @@ -107,15 +107,25 @@ Then activate your environment by running the following: conda env create -f environment.yml # activate the environment conda activate meld_graph -# add the torch packages -pip install --no-cache-dir torch==1.10.0+cu113 torchvision==0.11.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html && pip install -e . && pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu111.html && pip install torch-geometric==2.4.0 +# add the torch CPU packages (see below for GPU) +pip install --no-cache-dir torch==1.10.0 torchvision==0.11.1 && pip install -e . && pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0.html && pip install torch-geometric==2.4.0 && pip install captum==0.6.0 +# for use of GPU , install the Torch packages below instead +# pip install --no-cache-dir torch==1.10.0+cu113 torchvision==0.11.1+cu113 && pip install -e . && pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu111.html && pip install torch-geometric==2.4.0 && pip install captum==0.6.0 # install meld_graph with pip (with `-e`, the development mode, to allow changes in the code to be immediately visible in the installation) pip install -e . ``` ::: :::: + + +## MELD license +In order to run MELD Graph you need to have a `meld_license.txt` in the meld graph folder. To get this file, please fill out the [MELD registration form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). Once submitted, your application will be automatically reviewed and the meld_license.txt file will be send to your email. + ## Set up paths and download model + +First, you will need to copy the MELD `meld_license.txt` into the meld graph folder (see above how to get the MELD license) + Before being able to use the classifier on your data, some paths need to be set up and the pretrained model needs to be downloaded. For this, run: ```bash ./meldgraph.sh prepare_classifier.py diff --git a/docs/install_singularity.md b/docs/install_singularity.md index 4601306..206c007 100644 --- a/docs/install_singularity.md +++ b/docs/install_singularity.md @@ -6,8 +6,8 @@ The Singularity container has been created to be used on HPC supporting Linux as Notes: - The Singularity image is built from the Docker container. -- You will need **~20GB of space** to install the container -- The image contains Miniconda 3, Freesurfer V7.2, Fastsurfer V1.1.2 and torch 1.10.0+cu113. The whole image is 20 GB. +- You will need **~13GB of space** to install the container +- The image contains Miniconda 3, Freesurfer V7.2, Fastsurfer V1.1.2 and torch 1.10.0. The whole image is 13 GB. ## Prerequisites @@ -22,10 +22,14 @@ If this command displays the singularity or apptainer version already installed. ## Freesurfer licence You will need to download a Freesurfer license.txt to enable Freesurfer/Fastsurfer to perform the segmentation. Please follow the [guidelines](https://surfer.nmr.mgh.harvard.edu/fswiki/License) to download the file and keep a record of the path where you saved it. +## MELD license +In order to run MELD Graph you need to have a `meld_license.txt` in the meld graph folder. To get this file, please fill out the [MELD registration form](https://docs.google.com/forms/d/e/1FAIpQLSdocMWtxbmh9T7Sv8NT4f0Kpev-tmRI-kngDhUeBF9VcZXcfg/viewform?usp=header). Once submitted, your application will be automatically reviewed and the meld_license.txt file will be send to your email. + + ## Configuration In order to run the singularity image, you'll need to build the singularity image from the meld_graph docker image. This will create a singularity image called meld_graph.sif where you ran the command. -Make sure you have 20GB of storage space available for the docker +Make sure you have 13GB of storage space available for the docker ```bash singularity build meld_graph.sif docker://meldproject/meld_graph:latest @@ -35,26 +39,30 @@ singularity build meld_graph.sif docker://meldproject/meld_graph:latest Before being able to use the classifier on your data, data paths need to be set up and the pretrained model needs to be downloaded. 1. Make sure you have 2GB available for the meld data. -2. Create the **meld_data** folder, if it doesn't exist already. This folder is where where you would like to store MRI data to run the classifier. -2. Run this command to set the paths needed: +2. Create the **meld_data** folder, if it doesn't exist already. This folder is where where you would like to store MRI data to run the classifier. +3. Run this command to set the paths needed: - : Add the path to meld_data folder -- : path where the license.txt has been saved +- : path where the Freesurfer `license.txt` has been saved +- : path where the MELD `meld_license.txt` has been saved + + ```bash -export SINGULARITY_BINDPATH=/:/data,/license.txt:/license.txt:ro +export SINGULARITY_BINDPATH=/:/data,/license.txt:/license.txt:ro,/meld_license.txt:/meld_license.txt:ro export SINGULARITYENV_FS_LICENSE=/license.txt +export SINGULARITYENV_MELD_LICENSE=/meld_license.txt ``` OR with Apptainer ```bash -export APPTAINER_BINDPATH=/:/data,/license.txt:/license.txt:ro +export APPTAINER_BINDPATH=/:/data,/license.txt:/license.txt:ro,/meld_license.txt:/meld_license.txt:ro export APPTAINERENV_FS_LICENSE=/license.txt +export APPTAINERENV_MELD_LICENSE=/meld_license.txt ``` :::{admonition} Singularity :class: tip You can add those paths to your `~/.bashrc` file to ensure they are always activated when opening a new terminal. ::: - -3. Run this command to download the data folder +4. Run this command to download the data folder ```bash singularity exec meld_graph.sif /bin/bash -c "cd /app && python scripts/new_patient_pipeline/prepare_classifier.py " ``` diff --git a/environment.yml b/environment.yml index ae97e47..578674c 100644 --- a/environment.yml +++ b/environment.yml @@ -1,6 +1,6 @@ name: meld_graph channels: - - pytorch + # - pytorch - defaults - conda-forge dependencies: @@ -11,10 +11,10 @@ dependencies: - fpdf=1.7.2 - scikit-image=0.18 - pip=23.3.1 - - cpuonly + # - cpuonly - pip: - potpourri3d==0.0.6 - - captum==0.6.0 + # - captum==0.6.0 - pandas==1.4.1 - matplotlib==3.5.1 - neuroCombat==0.2.12 diff --git a/meld_graph/__init__.py b/meld_graph/__init__.py index 7793c91..0ea5cce 100644 --- a/meld_graph/__init__.py +++ b/meld_graph/__init__.py @@ -1,3 +1,3 @@ __author__ = __maintainer__ = "MELD development team" __email__ = "meld.study@gmail.com" -__version__ = "2.2.3" \ No newline at end of file +__version__ = "2.2.4" \ No newline at end of file diff --git a/meld_graph/test/test_meld_license.py b/meld_graph/test/test_meld_license.py new file mode 100644 index 0000000..dd882f3 --- /dev/null +++ b/meld_graph/test/test_meld_license.py @@ -0,0 +1,31 @@ +import os +import sys +import re +from pathlib import Path + +def test_license(): + + # Get the meld license variable + meld_license_file = os.getenv("MELD_LICENSE", None) + + if meld_license_file is None: + print('ERROR: Could not find a MELD_LICENSE environment variable. Please ensure you have exported the MELD_LICENSE environment following the MELD Graph installation guidelines') + sys.exit() + if not os.path.isfile(meld_license_file): + print(f'ERROR: The file {meld_license_file} does not exist.\nPlease ensure you got the meld license file by filling the registration form provided in the MELD Graph installation guidelines and provided the right path to the file') + sys.exit() + + # check that the license is correct + text = Path(meld_license_file).read_text() + m = re.search(r"License\s*ID[:\s]*([0-9]+)", text, re.IGNORECASE) + if m: + license_id = m.group(1) + if not len(license_id) == 6: + print("ERROR: The license ID provided does not seem correct.\nPlease ensure you got the correct meld license file by filling the registration form provided in the MELD Graph installation guidelines and provided the right path to the file") + sys.exit() + else: + print(f"ERROR: The license file {meld_license_file} does not seem correct.\nPlease ensure you got the correct meld license file by filling the registration form provided in the MELD Graph installation guidelines and provided the right path to the file") + sys.exit() + +# call the test +test_license() \ No newline at end of file diff --git a/meldgraph.sh b/meldgraph.sh index 9dd1840..486c08d 100755 --- a/meldgraph.sh +++ b/meldgraph.sh @@ -1,5 +1,7 @@ #!/bin/bash +export MELD_LICENSE='meld_license.txt' + eval "$(conda shell.bash hook)" conda activate meld_graph diff --git a/scripts/__init__.py b/scripts/__init__.py index 1cfadf0..0ea5cce 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1,3 +1,3 @@ __author__ = __maintainer__ = "MELD development team" __email__ = "meld.study@gmail.com" -__version__ = "2.2.0" \ No newline at end of file +__version__ = "2.2.4" \ No newline at end of file diff --git a/scripts/manage_results/plot_prediction_report.py b/scripts/manage_results/plot_prediction_report.py index 4accbfb..b0089fd 100644 --- a/scripts/manage_results/plot_prediction_report.py +++ b/scripts/manage_results/plot_prediction_report.py @@ -651,7 +651,7 @@ def generate_prediction_report( pdf = PDF(unit="mm") # unit of measurement pdf = PDF(format="A4") # page format. A4 is the default value of the format, you don't have to specify it. - logo = os.path.join(SCRIPTS_DIR, "MELD_logo.png") + logo = os.path.join(SCRIPTS_DIR, "docs", "images", "MELD_logo.png") text_info_1 = "Information: \n The MRI data of this patient has been processed through the MELD Graph surface-based FCD detection algorithm. \n Page 1 of this report will show all detected clusters on an inflated view of the brain. \n Subsequent pages characterise individual predicted clusters sorted in descending confidence. \n The last page summarises the software version used to create this report." @@ -663,6 +663,19 @@ def generate_prediction_report( text_info_3 = get_info_soft(subject.subject_id, harmo_code, exp) + #### create first page with disclaimer and intended use + # add page + pdf.add_page() + # add line contours + pdf.lines() + # add header + pdf.custom_header(logo, txt1="MELD report", txt2=f"") + # add 1st page report image + im_1stpage = os.path.join(SCRIPTS_DIR, "docs", "images", f"1st_page_report.jpg") + pdf.image(im_1stpage, 10, 40, link='', type='', w=190, h=200) + # add footer date + pdf.custom_footer(footer_txt) + #### create main page with overview on inflated brain # add page pdf.add_page() diff --git a/scripts/new_patient_pipeline/new_pt_pipeline.py b/scripts/new_patient_pipeline/new_pt_pipeline.py index cc5b076..e449279 100644 --- a/scripts/new_patient_pipeline/new_pt_pipeline.py +++ b/scripts/new_patient_pipeline/new_pt_pipeline.py @@ -100,6 +100,12 @@ def flush(self): args = parser.parse_args() print(args) + + #--------------------------------------------------------------------------------- + ### Test meld license exists + from meld_graph.test.test_meld_license import test_license + test_license() + #--------------------------------------------------------------------------------- ### Create demographic file for prediction if not provided demographic_file_tmp = DEMOGRAPHIC_FEATURES_FILE diff --git a/scripts/new_patient_pipeline/prepare_classifier.py b/scripts/new_patient_pipeline/prepare_classifier.py index 97bd6dd..7d2ba69 100644 --- a/scripts/new_patient_pipeline/prepare_classifier.py +++ b/scripts/new_patient_pipeline/prepare_classifier.py @@ -6,7 +6,6 @@ import subprocess - def prepare_meld_config(): # get scripts dir (parent dir of dir that this file is in) SCRIPTS_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -82,6 +81,12 @@ def get_path_input(): from meld_graph.download_data import get_test_data, get_model, get_meld_params + #--------------------------------------------------------------------------------- + ### Test meld license exists + from meld_graph.test.test_meld_license import test_license + test_license() + #--------------------------------------------------------------------------------- + if args.update_test: get_test_data(force_download=True) print('Test data updated') diff --git a/scripts/new_patient_pipeline/run_script_prediction.py b/scripts/new_patient_pipeline/run_script_prediction.py index d4fb72d..bd18425 100644 --- a/scripts/new_patient_pipeline/run_script_prediction.py +++ b/scripts/new_patient_pipeline/run_script_prediction.py @@ -223,6 +223,13 @@ def run_script_prediction(list_ids=None, sub_id=None, harmo_code='noHarmo', no_p args = parser.parse_args() print(args) + #--------------------------------------------------------------------------------- + ### Test meld license exists + from meld_graph.test.test_meld_license import test_license + test_license() + #--------------------------------------------------------------------------------- + + ### Create demographic file for prediction if not provided demographic_file_tmp = DEMOGRAPHIC_FEATURES_FILE if args.demographic_file is None: diff --git a/scripts/new_patient_pipeline/run_script_preprocessing.py b/scripts/new_patient_pipeline/run_script_preprocessing.py index 3a03fcf..63444ea 100644 --- a/scripts/new_patient_pipeline/run_script_preprocessing.py +++ b/scripts/new_patient_pipeline/run_script_preprocessing.py @@ -318,6 +318,12 @@ def run_script_preprocessing(list_ids=None, sub_id=None, harmo_code='noHarmo', o args = parser.parse_args() print(args) + + #--------------------------------------------------------------------------------- + ### Test meld license exists + from meld_graph.test.test_meld_license import test_license + test_license() + #--------------------------------------------------------------------------------- ### Create demographic file for prediction if not provided demographic_file_tmp = DEMOGRAPHIC_FEATURES_FILE diff --git a/scripts/new_patient_pipeline/run_script_segmentation.py b/scripts/new_patient_pipeline/run_script_segmentation.py index a2b74dd..d812eb6 100644 --- a/scripts/new_patient_pipeline/run_script_segmentation.py +++ b/scripts/new_patient_pipeline/run_script_segmentation.py @@ -446,6 +446,12 @@ def run_script_segmentation(list_ids=None, sub_id=None, harmo_code='noHarmo', us args = parser.parse_args() print(args) + #--------------------------------------------------------------------------------- + ### Test meld license exists + from meld_graph.test.test_meld_license import test_license + test_license() + #--------------------------------------------------------------------------------- + ### Create demographic file for prediction if not provided demographic_file_tmp = DEMOGRAPHIC_FEATURES_FILE if args.demographic_file is None: diff --git a/setup.py b/setup.py index 228a13f..34ca257 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: __author__ = __maintainer__ = "MELD development team" __email__ = "meld.study@gmail.com" - __version__ = "2.2.3" + __version__ = "2.2.4" setup( name="meld_graph",