enigma_stacking_pred.def 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Bootstrap: docker
  2. FROM: python:3.11.6-slim-bookworm
  3. Stage: base
  4. %setup
  5. # touch ${SINGULARITY_ROOTFS}/data
  6. %files
  7. save_feat.py /codes/
  8. predict_age_stacking.py /codes/
  9. analysis.sh /codes/
  10. %environment
  11. #
  12. %post
  13. pip install --upgrade pip
  14. pip install "scikit-learn==1.3.2" \
  15. "nibabel==4.0.2" \
  16. "nilearn==0.9.0" \
  17. "numpy==1.25.2" \
  18. "pandas==1.5.3" \
  19. "joblib==1.4.2" \
  20. "julearn==0.3.1"
  21. mkdir /model/
  22. mkdir /data/
  23. mkdir /extras
  24. # mkdir /codes
  25. # cp save_feat.py /codes/
  26. # cp predict_age_stacking.py /codes/
  27. # cp analysis.sh /codes/
  28. chmod +x /codes/*
  29. apt-get -y update && apt-get install -y unzip wget
  30. apt-get -y --quiet --no-install-recommends install build-essential curl ca-certificates
  31. curl https://gin.g-node.org/antogeo/stacking_model/raw/68c8723a15badbac0c26bf3d40aa9ba31264ea4a/extras/mask_4mm_binarized.nii --output /extras/mask_4mm_binarized.nii
  32. curl https://gin.g-node.org/antogeo/stacking_model/raw/68c8723a15badbac0c26bf3d40aa9ba31264ea4a/extras/mask_8mm_binarized.nii --output /extras/mask_8mm_binarized.nii
  33. curl https://gin.g-node.org/antogeo/stacking_model/raw/68c8723a15badbac0c26bf3d40aa9ba31264ea4a/extras/brainmask_12.8.nii --output /extras/brainmask_12.8.nii
  34. wget https://gin.g-node.org/antogeo/stacking_model/raw/master/stacking_enigmaModel%281%29.pkl -O /model/stacking_enigmaModel.pkl
  35. chmod +rw /extras/*
  36. # Octave
  37. # add-apt-repository 'http://ftp.debian.org/debian/ stable main contrib non-free'
  38. DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install octave liboctave-dev
  39. mkdir /opt/spm12
  40. curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1
  41. curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0
  42. make -C /opt/spm12/src PLATFORM=octave distclean
  43. make -C /opt/spm12/src PLATFORM=octave
  44. make -C /opt/spm12/src PLATFORM=octave install
  45. ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12
  46. rm -f /opt/spm12/src/*.{mex,o,a}
  47. apt-get --yes remove build-essential curl liboctave-dev
  48. apt-get --yes autoremove
  49. apt-get --yes clean
  50. %environment
  51. export SPM_HOME=/opt/spm12
  52. %runscript
  53. # # cp $1 /data
  54. # echo "Starting age prediction for following subject/subjects"
  55. # echo "predict subject's : $1"
  56. # exec echo "$1"
  57. bash /codes/analysis.sh "$@"
  58. %startscript
  59. %test
  60. grep -q NAME=\"Ubuntu\" /etc/os-release
  61. if [ "$(ls -A /data/)" ]; then
  62. echo "No data provided"
  63. else
  64. echo "Data found in data"
  65. fi
  66. %labels
  67. Author: Antonopoulos Georgios https://github.com/antogeo
  68. Version v0.0.1
  69. %help
  70. This def file builds a Singularity container with a brain-age prediction model based on
  71. "BrainAGE: Revisited and reframed machine learning workflow", Polona Kalc et al.
  72. It gets GMV and WMV nifti as inputs and predicts the age of the subject.
  73. You need to run the following command prior to building the container:
  74. > chmod -R 777 /tmp 255 !
  75. At first, it extracts the features by performing resampling (4mm and 8mm) and smoothing
  76. (4mm and 8mm) to the image. Four different combinations of resampling and smoothing of
  77. the two tissue images result in 8 different groups of features.