Open Nilser3 opened 10 months ago
We don't need everything to be gathered within only one script.py
. Actually, for better comprehension, we should split the different functions (dicom2niftii, docker creation...)
Hi @NathanMolinier , some feedbacks
Using the pydicom-seg library, I managed to keep all the metadata of the input
in the output
.
Also, the issue of having different input
output
orientations was solved (tested on RAI and ASL orientations).
For preserve the colors and Label names (based on FreeSurferColorLUT.txt
), Label.json
files have been created for each class (additional information is configured there), in the templates folder, based on qiicr.org.
Slicer 5.6.1
Visualization--dicom_out_dir
after run script.pydicom file
, and all dicom files in a output folder
. Great work @Nilser3 ! Once you're done with your code, just create a Pull Request, I will check what you did !
The script.py has been updated with the following:
dicom_input_dir
has several subfolders, the script will run in each of these subfolders.dicom_output_dir
the same arborescence as dicom_input_dir
, only that it will contain the segmentations.dicom_output_dir
tree dcm_seg
dcm_seg
└── PPMI
└── 100001
├── 3D_T2_FLAIR
│ └── 2020-10-07_13_51_32.0
│ └── I1473191
│ └── 02_Left-Cerebral-White-Matter_WMH_SynthSeg.dcm
│ └── .
│ └── .
│ └── .
└── SAG_3D_MPRAGE
├── 2020-10-07_13_51_32.0
│ └── I1473172
│ └── 02_Left-Cerebral-White-Matter_WMH_SynthSeg.dcm
│ └── .
│ └── .
│ └── .
└── 2022-11-29_14_47_02.0
│ └── I1658546
│ └── 02_Left-Cerebral-White-Matter_WMH_SynthSeg.dcm
│ └── .
│ └── .
│ └── .
@NathanMolinier , Ready for a PR 😊
To create our container, we must have in a single folder containing :
Inside this folder we create a dockerfile
with the following content.
docker build -t freesurfer-wmhsyntheseg .
# Use an Ubuntu image
FROM freesurfer-wmhsyntheseg
# Install git and other necessary dependencies
RUN apt-get update && \
apt-get install -y git python3 python3-pip && \
rm -rf /var/lib/apt/lists/*
# Sets the working directory to /app
WORKDIR /app
COPY . /app
# Update pip and setuptools
RUN pip3 install --upgrade pip setuptools
# Install other dependencies
RUN pip3 install -r requirements.txt
RUN pip3 install -e .
COPY run.sh /app/run.sh
# Sets the default command to run when the container starts up
ENTRYPOINT ["/app/run.sh"]
docker build -t registre.apps.ul-pca-pr-ul01.ulaval.ca/ul-val-prj-pim-pr/freesurfer-wmhsyntheseg:0.0.3 .
docker push registre.apps.ul-pca-pr-ul01.ulaval.ca/ul-val-prj-pim-pr/freesurfer-wmhsyntheseg:0.0.3
docker run -v /USER_IN_PATH:/in:ro -v /USER_OUT_PATH:/out:rw registre.apps.ul-pca-pr-ul01.ulaval.ca/ul-val-prj-pim-pr/freesurfer-wmhsyntheseg:0.0.3 /in /out
Description
The strategy to implement pre-trained models in PARADIM is to do it via Docker and using a
script.py
that take adicom folder as input
and generate adicom folder as output
(segmentation) keeping the same metadata.Pretrained model that we want to implement is WMH-SynthSeg and is implemented in freesurfer-linux-ubuntu22_x86_64-dev-20240112-88246c0
Scripting
This script.py does:
To test it on Dicom data, here is a subject from PPMI project, using:
python script.py --dicom_dir Dicom_1 --dicom_out_dir Dicom_2
But I need to improve the parser of several Dicom folders, as well as preserve the entire metadata in Dicom_2.
Dockerizing
I made a first Freesurfer docker image, available in:
and for test scrpit.py with Dicom_1:
(here the Processing is just a
mri_convert
for reslicing, just to see the functionality of this docker image)@NathanMolinier feedback please 😊