MIC-DKFZ / MedNeXt

[MICCAI 2023] MedNeXt is a fully ConvNeXt architecture for 3D medical image segmentation.
https://arxiv.org/pdf/2303.09975
Apache License 2.0
324 stars 24 forks source link

nnUNet_plan_and_preprocess: command not found #4

Closed FriedaSmith closed 11 months ago

FriedaSmith commented 1 year ago
(MedNeXt) zw@T640:~/myData/Code/study/MedNeXt$ pip install -U .
Processing /home/zw/myData/Code/study/MedNeXt
  Preparing metadata (setup.py) ... done
Requirement already satisfied: torch>1.10.0 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (1.12.1+cu113)
Requirement already satisfied: tqdm in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (4.65.0)
Requirement already satisfied: dicom2nifti in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (2.4.8)
Requirement already satisfied: scikit-image>=0.14 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (0.21.0)
Requirement already satisfied: medpy in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (0.4.0)
Requirement already satisfied: scipy in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (1.11.1)
Requirement already satisfied: batchgenerators>=0.23 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (0.25)
Requirement already satisfied: numpy in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (1.25.1)
Requirement already satisfied: sklearn in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (0.0.post5)
Requirement already satisfied: SimpleITK in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (2.2.1)
Requirement already satisfied: pandas in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (2.0.3)
Requirement already satisfied: requests in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (2.31.0)
Requirement already satisfied: nibabel in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (5.1.0)
Requirement already satisfied: tifffile in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (2023.7.10)
Requirement already satisfied: matplotlib in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from mednextv1==1.7.0) (3.7.2)
Requirement already satisfied: unittest2 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from batchgenerators>=0.23->mednextv1==1.7.0) (1.1.0)
Requirement already satisfied: pillow>=7.1.2 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from batchgenerators>=0.23->mednextv1==1.7.0) (10.0.0)
Requirement already satisfied: threadpoolctl in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from batchgenerators>=0.23->mednextv1==1.7.0) (3.2.0)
Requirement already satisfied: scikit-learn in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from batchgenerators>=0.23->mednextv1==1.7.0) (1.3.0)
Requirement already satisfied: future in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from batchgenerators>=0.23->mednextv1==1.7.0) (0.18.3)
Requirement already satisfied: packaging>=21 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from scikit-image>=0.14->mednextv1==1.7.0) (23.1)
Requirement already satisfied: PyWavelets>=1.1.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from scikit-image>=0.14->mednextv1==1.7.0) (1.4.1)
Requirement already satisfied: imageio>=2.27 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from scikit-image>=0.14->mednextv1==1.7.0) (2.31.1)
Requirement already satisfied: lazy_loader>=0.2 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from scikit-image>=0.14->mednextv1==1.7.0) (0.3)
Requirement already satisfied: networkx>=2.8 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from scikit-image>=0.14->mednextv1==1.7.0) (3.1)
Requirement already satisfied: typing-extensions in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from torch>1.10.0->mednextv1==1.7.0) (4.7.1)
Requirement already satisfied: pydicom>=2.2.0 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from dicom2nifti->mednextv1==1.7.0) (2.4.1)
Requirement already satisfied: python-gdcm in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from dicom2nifti->mednextv1==1.7.0) (3.0.22)
Requirement already satisfied: python-dateutil>=2.7 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (2.8.2)
Requirement already satisfied: importlib-resources>=3.2.0 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (6.0.0)
Requirement already satisfied: fonttools>=4.22.0 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (4.41.0)
Requirement already satisfied: cycler>=0.10 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (0.11.0)
Requirement already satisfied: pyparsing<3.1,>=2.3.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (3.0.9)
Requirement already satisfied: contourpy>=1.0.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (1.1.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from matplotlib->mednextv1==1.7.0) (1.4.4)
Requirement already satisfied: tzdata>=2022.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from pandas->mednextv1==1.7.0) (2023.3)
Requirement already satisfied: pytz>=2020.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from pandas->mednextv1==1.7.0) (2023.3)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from requests->mednextv1==1.7.0) (2.0.3)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from requests->mednextv1==1.7.0) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from requests->mednextv1==1.7.0) (3.4)
Requirement already satisfied: certifi>=2017.4.17 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from requests->mednextv1==1.7.0) (2023.5.7)
Requirement already satisfied: zipp>=3.1.0 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib->mednextv1==1.7.0) (3.16.2)
Requirement already satisfied: six>=1.5 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib->mednextv1==1.7.0) (1.16.0)
Requirement already satisfied: joblib>=1.1.1 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from scikit-learn->batchgenerators>=0.23->mednextv1==1.7.0) (1.3.1)
Collecting argparse
  Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: traceback2 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from unittest2->batchgenerators>=0.23->mednextv1==1.7.0) (1.4.0)
Requirement already satisfied: linecache2 in /home/zw/anaconda3/envs/MedNeXt/lib/python3.9/site-packages (from traceback2->unittest2->batchgenerators>=0.23->mednextv1==1.7.0) (1.0.0)
Building wheels for collected packages: mednextv1
  Building wheel for mednextv1 (setup.py) ... done
  Created wheel for mednextv1: filename=mednextv1-1.7.0-py3-none-any.whl size=6208 sha256=c9ccdbaa5ac24225ac78b695ff226ff4d1ca691544b000b4c5432e27ca94cd38
  Stored in directory: /tmp/pip-ephem-wheel-cache-s6lt09cy/wheels/af/0b/8e/386d902d82d2285808083f810f5d24690a7e29e5b76861f907
Successfully built mednextv1
Installing collected packages: argparse, mednextv1
Successfully installed argparse-1.4.0 mednextv1-1.7.0
(MedNeXt) zw@T640:~/myData/Code/study/MedNeXt$ nnUNet_plan_and_preprocess -t 1
nnUNet_plan_and_preprocess: command not found

python version: 3.9.13 pytorch version: 1.12.1+cu113

FriedaSmith commented 1 year ago

I used the Python command and also reported an error. The dataset path is as follows:

(MedNeXt) zw@T640:~/myData/Code/study/MedNeXt$ ls "/home/zw/myData/Code/study/nnUNet_raw_data_base/nnUNet_raw_data/Dataset001_Tr"
dataset.json  imagesTr  imagesTs  infers  labelsTr
(MedNeXt) zw@T640:~/myData/Code/study/MedNeXt$ python "/home/zw/myData/Code/study/MedNeXt/nnunet_mednext/experiment_planning/nnUNet_plan_and_preprocess.py" -t 1
Traceback (most recent call last):
  File "/home/zw/myData/Code/study/MedNeXt/nnunet_mednext/experiment_planning/nnUNet_plan_and_preprocess.py", line 170, in <module>
    main()
  File "/home/zw/myData/Code/study/MedNeXt/nnunet_mednext/experiment_planning/nnUNet_plan_and_preprocess.py", line 102, in main
    task_name = convert_id_to_task_name(i)
  File "/home/zw/myData/Code/study/MedNeXt/nnunet_mednext/utilities/task_name_id_conversion.py", line 51, in convert_id_to_task_name
    raise RuntimeError("Could not find a task with the ID %d. Make sure the requested task ID exists and that "
RuntimeError: Could not find a task with the ID 1. Make sure the requested task ID exists and that nnU-Net knows where raw and preprocessed data are located (see Documentation - Installation). Here are your currently defined folders:
nnUNet_preprocessed=/home/zw/myData/Code/study/nnUNet_preprocessed
RESULTS_FOLDER=/home/zw/myData/Code/study/nnUNet_trained_models
nnUNet_raw_data_base=/home/zw/myData/Code/study/nnUNet_raw_data_base
If something is not right, adapt your environemnt variables.
saikat-roy commented 1 year ago

Hey @FriedaSmith. I haven't had the time to clean the preprocessing or nnunet training yet - or even release all the code for to do the preprocessing.

But maybe I can add something I notice in your code. Your code seems to be processed based on nnUNet (v2) format. This is what the main branch of nnUNet supports at the moment. My model was trained using nnUNet (v1) which you will find in a branch of the nnUNet repo (https://github.com/MIC-DKFZ/nnUNet/tree/nnunetv1).

You are free to use my model inside nnunet v2 if you have experience with replacing the model inside an nnUNetTrainer. Or wait a little more for me to clean/release code for data preparation and training as part of this repository.

saikat-roy commented 11 months ago

There is code and instructions now to recreate the MICCAI2023 experiments in nnUNet(v1). Please reopen this issue if you have more questions.