diff --git a/README.md b/README.md index d0ae872..0aabc26 100644 --- a/README.md +++ b/README.md @@ -16,41 +16,78 @@ } ``` ## Dataset -Please refer to challenge website [[link]](https://zmiclab.github.io/projects/myops20/) for dataset access. +Please refer to challenge website [[link]](https://zmiclab.github.io/projects/myops20/) for dataset access. The dataset contains three folders: train25, train25_myops_gd, test20. ## Environment 1. UNet: - +``` +conda env create -f myops_unet.yml +``` 2. Mask-RCNN and UNet++: +``` +conda env create -f myops_mrcnn_unetpp.yml +``` +## Default directory structure -## Default files + ├── Data + | ├── Original_data # Place the downloaded dataset here + | | ├── train25 + | | ├── train25_myops_gd + | | ├── test20 + ├── mask_rcnn_coco.h5 # Downloaded pre-trained mask_rcnn weights + ├── config.py + ├── data_creator.py + ├── ... ## Setup -1. Preprocessing - - Extract dataset to 2D slices +1. Data creator including random warping augmentation +``` +python data_creator.py +``` + +2. Train networks + - Train UNet for LV_BP, RV_BP, LV_NM, LV_ME, LV_MS blocks ``` - python data_creator.py + python train_UNet.py + ``` + - Train Mask-RCNN for LV_ME and LV_MS blocks + - Download pretrained mask_rcnn_coco.h5 at [[here]](https://github.com/matterport/Mask_RCNN/releases) and place it in the current folder. + - Train Mask-RCNN for LV_ME block + ``` + python train_MaskRCNN.py --mode 'LV_ME' + ``` + - Train Mask-RCNN for LV_MS block + ``` + python train_MaskRCNN.py --mode 'LV_MS' + ``` + - Train UNet++ for LV_ME and LV_MS blocks + ``` + python train_UNetplusplus.py ``` - -2. Train networks - - Train UNet for - - Train Mask-RCNN - - Download mrcnn_coco.h5 - - - - Train UNet++ for - 3. Test networks: - Test UNet + ``` + python test_UNet.py + ``` - Test Mask-RCNN - - Test UNet++ - -4. Post-processing and linear decoder: - - Post processing + - Test LV_ME block + ``` + python test_MaskRCNN.py --mode 'LV_ME' + ``` + - Test LV_MS block + ``` + python test_MaskRCNN.py --mode 'LV_MS' + ``` + - Test UNet++ ``` - python post_processing.py + python test_UNetplusplus.py ``` +4. Post-processing and linear decoder: +``` +python post_processing.py +``` ## Acknowledgement 1. Please cite the official Mask-RCNN and UNet++ implementations if you use them: - Mask-RCNN: https://github.com/matterport/Mask_RCNN diff --git a/helper.py b/helper.py index 7c819ab..f107f05 100644 --- a/helper.py +++ b/helper.py @@ -235,19 +235,14 @@ def func_saveTrainingDataIntoSlices(destPath, train_inputs, train_labels, mode): np.save(os.path.join(destPath_label, str(i+1)+'.npy'), train_labels[i]) def func_createLabelToMask(label,myo_type): - - #print(type(label)) - #print(label.shape) size_x,size_y = label.shape mask = np.zeros(shape=(size_x,size_y)) - #indices = [(row,col.index(class_values[i])) for row, col in enumerate(list(label)) if class_values[i] in row] if myo_type == 'LV_MS' or myo_type == 'BG': indices = np.where(label==class_values_mrcnn_dict[myo_type]) x = indices[0] y = indices[1] for j in range(indices[0].shape[0]): - #print(x[j],y[j]) mask[(x[j],y[j])] = 1 return mask @@ -255,9 +250,6 @@ def func_createLabelToMask(label,myo_type): if myo_type == 'LV_ME': indices = np.where(label==class_values_mrcnn_dict[myo_type]) indices_LVMS = np.where(label==LV_MS) - #print(type(indices[1])) - #print(len(indices)) - #print(indices[0].shape) x = indices[0] y = indices[1] for j in range(indices[0].shape[0]): diff --git a/myops_mrcnn_unetpp.yml b/myops_mrcnn_unetpp.yml new file mode 100644 index 0000000..39ea089 --- /dev/null +++ b/myops_mrcnn_unetpp.yml @@ -0,0 +1,139 @@ +name: myo20_mrcnn +channels: +- defaults +dependencies: +- _libgcc_mutex=0.1=main +- _tflow_select=2.1.0=gpu +- absl-py=0.9.0=py36_0 +- astor=0.8.0=py36_0 +- backcall=0.2.0=py_0 +- blas=1.0=mkl +- bzip2=1.0.8=h7b6447c_0 +- c-ares=1.15.0=h7b6447c_1001 +- ca-certificates=2020.6.24=0 +- cairo=1.14.12=h8948797_3 +- certifi=2020.6.20=py36_0 +- cloudpickle=1.5.0=py_0 +- cudatoolkit=10.0.130=0 +- cudnn=7.6.5=cuda10.0_0 +- cupti=10.0.130=0 +- cycler=0.10.0=py36_0 +- cytoolz=0.10.1=py36h7b6447c_0 +- dask-core=2.20.0=py_0 +- dbus=1.13.16=hb2f20db_0 +- decorator=4.4.2=py_0 +- expat=2.2.9=he6710b0_2 +- ffmpeg=4.0=hcdf2ecd_0 +- fontconfig=2.13.0=h9420a91_0 +- freeglut=3.0.0=hf484d3e_5 +- freetype=2.10.2=h5ab3b9f_0 +- gast=0.2.2=py36_0 +- glib=2.65.0=h3eb4bd4_0 +- google-pasta=0.2.0=py_0 +- graphite2=1.3.14=h23475e2_0 +- grpcio=1.27.2=py36hf8bcb03_0 +- gst-plugins-base=1.14.0=hbbd80ab_1 +- gstreamer=1.14.0=hb31296c_0 +- h5py=2.8.0=py36h61e79e4_3 +- harfbuzz=1.8.8=hffaf4a1_0 +- hdf5=1.8.20=hba1933b_1 +- icu=58.2=he6710b0_3 +- imageio=2.9.0=py_0 +- intel-openmp=2020.1=217 +- ipykernel=5.3.4=py36h5ca1d4c_0 +- ipython=7.16.1=py36h5ca1d4c_0 +- ipython_genutils=0.2.0=py36_0 +- jasper=2.0.14=h07fcdf6_1 +- jedi=0.17.1=py36_0 +- joblib=1.0.1=pyhd3eb1b0_0 +- jpeg=9b=h024ee3a_2 +- jupyter_client=6.1.12=pyhd3eb1b0_0 +- jupyter_core=4.7.1=py36h06a4308_0 +- keras=2.3.1=0 +- keras-applications=1.0.8=py_1 +- keras-base=2.3.1=py36_0 +- keras-preprocessing=1.1.0=py_1 +- kiwisolver=1.2.0=py36hfd86e86_0 +- lcms2=2.11=h396b838_0 +- ld_impl_linux-64=2.33.1=h53a641e_7 +- libedit=3.1.20191231=h14c3975_1 +- libffi=3.3=he6710b0_2 +- libgcc-ng=9.1.0=hdf63c60_0 +- libgfortran-ng=7.3.0=hdf63c60_0 +- libglu=9.0.0=hf484d3e_1 +- libopencv=3.4.2=h765d7f9_1 +- libopus=1.3.1=h7b6447c_0 +- libpng=1.6.37=hbc83047_0 +- libprotobuf=3.12.3=hd408876_0 +- libsodium=1.0.18=h7b6447c_0 +- libstdcxx-ng=9.1.0=hdf63c60_0 +- libtiff=4.1.0=h2733197_1 +- libuuid=1.0.3=h1bed415_2 +- libvpx=1.7.0=h439df22_0 +- libxcb=1.14=h7b6447c_0 +- libxml2=2.9.10=he19cac6_1 +- lz4-c=1.9.2=he6710b0_0 +- markdown=3.1.1=py36_0 +- matplotlib=3.2.2=0 +- matplotlib-base=3.2.2=py36hef1b27d_0 +- mkl=2020.1=217 +- mkl-service=2.3.0=py36he904b0f_0 +- mkl_fft=1.1.0=py36h23d657b_0 +- mkl_random=1.1.1=py36h0573a6f_0 +- ncurses=6.2=he6710b0_1 +- networkx=2.4=py_1 +- numpy=1.18.5=py36ha1c710e_0 +- numpy-base=1.18.5=py36hde5b4d6_0 +- olefile=0.46=py_0 +- opencv=3.4.2=py36h40b0b35_1 +- openssl=1.1.1g=h7b6447c_0 +- opt_einsum=3.1.0=py_0 +- parso=0.7.0=py_0 +- pcre=8.44=he6710b0_0 +- pexpect=4.8.0=py36_0 +- pickleshare=0.7.5=py36_0 +- pillow=7.2.0=py36hb39fc2d_0 +- pip=20.1.1=py36_1 +- pixman=0.40.0=h7b6447c_0 +- prompt-toolkit=3.0.5=py_0 +- protobuf=3.12.3=py36he6710b0_0 +- ptyprocess=0.6.0=py36_0 +- py-opencv=3.4.2=py36h765d7f9_1 +- pygments=2.6.1=py_0 +- pyparsing=2.4.7=py_0 +- pyqt=5.9.2=py36h05f1152_2 +- python=3.6.10=h7579374_2 +- python-dateutil=2.8.1=py_0 +- pywavelets=1.1.1=py36h7b6447c_0 +- pyyaml=5.3.1=py36h7b6447c_1 +- pyzmq=20.0.0=py36h2531618_1 +- qt=5.9.7=h5867ecd_1 +- readline=8.0=h7b6447c_0 +- scikit-image=0.16.2=py36h0573a6f_0 +- scipy=1.5.0=py36h0b6359f_0 +- setuptools=49.2.0=py36_0 +- sip=4.19.8=py36hf484d3e_0 +- six=1.15.0=py_0 +- sqlite=3.32.3=h62c20be_0 +- tensorboard=1.15.0=pyhb230dea_0 +- tensorflow=1.15.0=gpu_py36h5a509aa_0 +- tensorflow-base=1.15.0=gpu_py36h9dcbed7_0 +- tensorflow-estimator=1.15.1=pyh2649769_0 +- tensorflow-gpu=1.15.0=h0d30ee6_0 +- termcolor=1.1.0=py36_1 +- tk=8.6.10=hbc83047_0 +- toolz=0.10.0=py_0 +- tornado=6.0.4=py36h7b6447c_1 +- traitlets=4.3.3=py36_0 +- wcwidth=0.2.5=py_0 +- webencodings=0.5.1=py36_1 +- werkzeug=0.16.1=py_0 +- wheel=0.34.2=py36_0 +- wrapt=1.12.1=py36h7b6447c_1 +- xz=5.2.5=h7b6447c_0 +- yaml=0.2.5=h7b6447c_0 +- zeromq=4.3.4=h2531618_0 +- zlib=1.2.11=h7b6447c_3 +- zstd=1.4.4=h0b5b093_3 +prefix: /home/xiaoran8/.local/easybuild/software/2017/Core/miniconda3/4.3.27/envs/myo20_mrcnn + diff --git a/myops_unet.yml b/myops_unet.yml new file mode 100644 index 0000000..3685c6a --- /dev/null +++ b/myops_unet.yml @@ -0,0 +1,146 @@ +name: myops_unet +channels: +- defaults +dependencies: +- _libgcc_mutex=0.1=main +- _tflow_select=2.1.0=gpu +- absl-py=0.13.0=pyhd3eb1b0_0 +- aiohttp=3.7.4=py39h27cfd23_1 +- astor=0.8.1=py39h06a4308_0 +- astunparse=1.6.3=py_0 +- async-timeout=3.0.1=py39h06a4308_0 +- attrs=21.2.0=pyhd3eb1b0_0 +- backcall=0.2.0=pyhd3eb1b0_0 +- blas=1.0=mkl +- blinker=1.4=py39h06a4308_0 +- brotlipy=0.7.0=py39h27cfd23_1003 +- c-ares=1.17.1=h27cfd23_0 +- ca-certificates=2021.7.5=h06a4308_1 +- cachetools=4.2.2=pyhd3eb1b0_0 +- certifi=2021.5.30=py39h06a4308_0 +- cffi=1.14.6=py39h400218f_0 +- chardet=3.0.4=py39h06a4308_1003 +- click=8.0.1=pyhd3eb1b0_0 +- coverage=5.5=py39h27cfd23_2 +- cryptography=3.4.7=py39hd23ed53_0 +- cudatoolkit=10.1.243=h6bb024c_0 +- cudnn=7.6.5=cuda10.1_0 +- cupti=10.1.168=0 +- cycler=0.10.0=py39h06a4308_0 +- cython=0.29.24=py39h295c915_0 +- dbus=1.13.18=hb2f20db_0 +- decorator=5.0.9=pyhd3eb1b0_0 +- expat=2.4.1=h2531618_2 +- fontconfig=2.13.1=h6c09931_0 +- freetype=2.10.4=h5ab3b9f_0 +- gast=0.4.0=py_0 +- glib=2.68.2=h36276a3_0 +- google-auth=1.33.0=pyhd3eb1b0_0 +- google-auth-oauthlib=0.4.4=pyhd3eb1b0_0 +- google-pasta=0.2.0=py_0 +- grpcio=1.36.1=py39h2157cd5_1 +- gst-plugins-base=1.14.0=h8213a91_2 +- gstreamer=1.14.0=h28cd5cc_2 +- h5py=2.10.0=py39hec9cf62_0 +- hdf5=1.10.6=hb1b8bf9_0 +- icu=58.2=he6710b0_3 +- idna=2.10=pyhd3eb1b0_0 +- importlib-metadata=3.10.0=py39h06a4308_0 +- intel-openmp=2021.2.0=h06a4308_610 +- ipykernel=5.3.4=py39hb070fc8_0 +- ipython=7.22.0=py39hb070fc8_0 +- ipython_genutils=0.2.0=pyhd3eb1b0_1 +- jedi=0.17.2=py39h06a4308_1 +- jpeg=9b=h024ee3a_2 +- jupyter_client=6.1.12=pyhd3eb1b0_0 +- jupyter_core=4.7.1=py39h06a4308_0 +- keras-preprocessing=1.1.2=pyhd3eb1b0_0 +- kiwisolver=1.3.1=py39h2531618_0 +- lcms2=2.12=h3be6417_0 +- ld_impl_linux-64=2.35.1=h7274673_9 +- libffi=3.3=he6710b0_2 +- libgcc-ng=9.1.0=hdf63c60_0 +- libgfortran-ng=7.3.0=hdf63c60_0 +- libpng=1.6.37=hbc83047_0 +- libprotobuf=3.14.0=h8c45485_0 +- libsodium=1.0.18=h7b6447c_0 +- libstdcxx-ng=9.1.0=hdf63c60_0 +- libtiff=4.2.0=h85742a9_0 +- libuuid=1.0.3=h1bed415_2 +- libwebp-base=1.2.0=h27cfd23_0 +- libxcb=1.14=h7b6447c_0 +- libxml2=2.9.10=hb55368b_3 +- lz4-c=1.9.3=h2531618_0 +- markdown=3.3.4=py39h06a4308_0 +- matplotlib=3.3.4=py39h06a4308_0 +- matplotlib-base=3.3.4=py39h62a2d02_0 +- mkl=2021.2.0=h06a4308_296 +- mkl-service=2.3.0=py39h27cfd23_1 +- mkl_fft=1.3.0=py39h42c9631_2 +- mkl_random=1.2.1=py39ha9443f7_2 +- multidict=5.1.0=py39h27cfd23_2 +- ncurses=6.2=he6710b0_1 +- numpy=1.20.2=py39h2d18471_0 +- numpy-base=1.20.2=py39hfae3a4d_0 +- oauthlib=3.1.1=pyhd3eb1b0_0 +- olefile=0.46=py_0 +- openssl=1.1.1k=h27cfd23_0 +- opt_einsum=3.3.0=pyhd3eb1b0_1 +- parso=0.7.0=py_0 +- pcre=8.45=h295c915_0 +- pexpect=4.8.0=pyhd3eb1b0_3 +- pickleshare=0.7.5=pyhd3eb1b0_1003 +- pillow=8.2.0=py39he98fc37_0 +- pip=21.1.3=py39h06a4308_0 +- prompt-toolkit=3.0.17=pyh06a4308_0 +- protobuf=3.14.0=py39h2531618_1 +- ptyprocess=0.7.0=pyhd3eb1b0_2 +- pyasn1=0.4.8=py_0 +- pyasn1-modules=0.2.8=py_0 +- pycparser=2.20=py_2 +- pygments=2.9.0=pyhd3eb1b0_0 +- pyjwt=2.1.0=py39h06a4308_0 +- pyopenssl=20.0.1=pyhd3eb1b0_1 +- pyparsing=2.4.7=pyhd3eb1b0_0 +- pyqt=5.9.2=py39h2531618_6 +- pysocks=1.7.1=py39h06a4308_0 +- python=3.9.5=h12debd9_4 +- python-dateutil=2.8.1=pyhd3eb1b0_0 +- python-flatbuffers=1.12=pyhd3eb1b0_0 +- pyzmq=20.0.0=py39h2531618_1 +- qt=5.9.7=h5867ecd_1 +- readline=8.1=h27cfd23_0 +- requests=2.25.1=pyhd3eb1b0_0 +- requests-oauthlib=1.3.0=py_0 +- rsa=4.7.2=pyhd3eb1b0_1 +- scipy=1.6.2=py39had2a1c9_1 +- setuptools=52.0.0=py39h06a4308_0 +- sip=4.19.13=py39h2531618_0 +- six=1.16.0=pyhd3eb1b0_0 +- sqlite=3.36.0=hc218d9a_0 +- tensorboard=2.4.0=pyhc547734_0 +- tensorboard-plugin-wit=1.6.0=py_0 +- tensorflow=2.4.1=gpu_py39h8236f22_0 +- tensorflow-base=2.4.1=gpu_py39h29c2da4_0 +- tensorflow-estimator=2.5.0=pyh7b7c402_0 +- tensorflow-gpu=2.4.1=h30adc30_0 +- termcolor=1.1.0=py39h06a4308_1 +- tk=8.6.10=hbc83047_0 +- tornado=6.1=py39h27cfd23_0 +- traitlets=5.0.5=pyhd3eb1b0_0 +- typing-extensions=3.10.0.0=hd3eb1b0_0 +- typing_extensions=3.10.0.0=pyh06a4308_0 +- tzdata=2021a=h52ac0ba_0 +- urllib3=1.26.6=pyhd3eb1b0_1 +- wcwidth=0.2.5=py_0 +- werkzeug=1.0.1=pyhd3eb1b0_0 +- wheel=0.36.2=pyhd3eb1b0_0 +- wrapt=1.12.1=py39he8ac12f_1 +- xz=5.2.5=h7b6447c_0 +- yarl=1.6.3=py39h27cfd23_0 +- zeromq=4.3.4=h2531618_0 +- zipp=3.5.0=pyhd3eb1b0_0 +- zlib=1.2.11=h7b6447c_3 +- zstd=1.4.9=haebb681_0 +prefix: /home/xiaoran8/.local/easybuild/software/2017/Core/miniconda3/4.3.27/envs/myops_unet +