Source code for our work "Bilateral Context Modeling for Residual Coding in Lossless 3D Medical Image Compression"
- Download MRNet test dataset from MRNet.
- Download MosMedData test dataset from Kaggle.
- Download TRABIT test dataset from Kaggle.
- Move the dataset to
{Data_Path}
, where{Data_Path}
is the directory to store data. The directory should be organized like:
{Data_Path}
- MRNet-v1.0
- valid
- axial
- 1130.npy
- ...
- coronal
- 1130.npy
- ...
- sagittal
- 1130.npy
- ...
- Mosmed_COVID-19_CT
- CT-3
- study_1064.nii
- ...
- TRABIT
- test
- mri_00539274.nii
- ...
Download pre-trained models from Google Driver.
You can refer to the following documents to install Docker and NVIDIA-Container-Toolkit on Ubuntu.
- go to the project directory.
- create a docker image.
docker build -t medical .
- create a docker container and run it.
docker run -it --name="BCM-Net" --gpus all --runtime=nvidia \ -v {Code_Path}:/home/Code -v {Models_Path}:/home/Models -v {Data_Path}:/home/Data \ -v {Experiment_Path}:/home/Experiment \ medical:latest
{Code_Path}
denotes the project directory path{Models_Path}
denotes the model directory path{Data_Path}
denotes the data directory path{Experiment_Path}
denotes the experimental directory path to save results
The following commands should be executed in the Docker container.
- go to the VTM folder.
cd /home/VVCSoftware_VTM
- compile VTM codec which supports 8/10bit input.
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release && make -j
- rename the compiled codec.
mv ../bin/EncoderAppStatic /home/VVC_Encoder_8bit && mv ../bin/DecoderAppStatic /home/VVC_Decoder_8bit
- set the macro
JVET_R0351_HIGH_BIT_DEPTH_ENABLED
to1
to support 16-bit input.nano ./source/Lib/CommonLib/TypeDef.h # then change line 84 and save the file
- compile VTM codec which supports 16bit input.
make clean && cmake .. -DCMAKE_BUILD_TYPE=Release && make -j
- rename the compiled codec.
mv ../bin/EncoderAppStatic /home/VVC_Encoder_16bit && mv ../bin/DecoderAppStatic /home//VVC_Decoder_16bit
The following commands should be executed in the Docker container.
🐛 Please modify the torch source file according to this PR before the test.
cd /home/Code && python3 TestMRNet.py --mr_net_root /home/Data/MRNet-v1.0/valid/axial --save_directory /home/Experiment/TestAxial \
--lossy_encoder_path /home/VVC_Encoder_8bit \
--lossy_decoder_path /home/VVC_Decoder_8bit \
--lossy_cfg_path /home/VVCSoftware_VTM/cfg/encoder_randomaccess_vtm_gop16.cfg /home/VVCSoftware_VTM/cfg/per-class/classSCC.cfg \
--qp 37 --checkpoints /home/Models/MRNet/Axial.pth --gpu
cd /home/Code && python3 TestMRNet.py --mr_net_root /home/Data/MRNet-v1.0/valid/coronal --save_directory /home/Experiment/TestCoronal \
--lossy_encoder_path /home/VVC_Encoder_8bit \
--lossy_decoder_path /home/VVC_Decoder_8bit \
--lossy_cfg_path /home/VVCSoftware_VTM/cfg/encoder_randomaccess_vtm_gop16.cfg /home/VVCSoftware_VTM/cfg/per-class/classSCC.cfg \
--qp 37 --checkpoints /home/Models/MRNet/Coronal.pth --gpu
cd /home/Code && python3 TestMRNet.py --mr_net_root /home/Data/MRNet-v1.0/valid/sagittal --save_directory /home/Experiment/TestSagittal \
--lossy_encoder_path /home/VVC_Encoder_8bit \
--lossy_decoder_path /home/VVC_Decoder_8bit \
--lossy_cfg_path /home/VVCSoftware_VTM/cfg/encoder_randomaccess_vtm_gop16.cfg /home/VVCSoftware_VTM/cfg/per-class/classSCC.cfg \
--qp 37 --checkpoints /home/Models/MRNet/Sagittal.pth --gpu
cd /home/Code && python3 TestMosMedData.py --mosmed_root /home/Data/Mosmed_COVID-19_CT/CT-3 --save_directory /home/Experiment/TestMosMedData \
--lossy_encoder_path /home/VVC_Encoder_16bit \
--lossy_decoder_path /home/VVC_Decoder_16bit \
--lossy_cfg_path /home/VVCSoftware_VTM/cfg/encoder_randomaccess_vtm_gop16.cfg /home/VVCSoftware_VTM/cfg/per-class/classSCC.cfg \
--qp 17 --checkpoints /home/Models/MosMedData/MosMedData.pth --gpu \
--bit_depth 16
cd /home/Code && python3 TestTRABIT.py --trabit_root /home/Data/TRABIT2019_MRI/test --save_directory /home/Experiment/TestTRABIT \
--lossy_encoder_path /home/VVC_Encoder_16bit \
--lossy_decoder_path /home/VVC_Decoder_16bit \
--lossy_cfg_path /home/VVCSoftware_VTM/cfg/encoder_randomaccess_vtm_gop16.cfg /home/VVCSoftware_VTM/cfg/per-class/classSCC.cfg \
--qp 0 --checkpoints /home/Models/TRABIT/TRABIT.pth --gpu \
--bit_depth 16
❤️❤️❤️ This work is implemented based on the following projects. We really appreciate their wonderful open-source work!
@ARTICLE{10478821,
author={Liu, Xiangrui and Wang, Meng and Wang, Shiqi and Kwong, Sam},
journal={IEEE Transactions on Image Processing},
title={Bilateral Context Modeling for Residual Coding in Lossless 3D Medical Image Compression},
year={2024},
volume={},
number={},
pages={1-1},
doi={10.1109/TIP.2024.3378910}}