Skip to content

Commit

Permalink
Merge pull request #5 from MEDomics-UdeS/dev
Browse files Browse the repository at this point in the history
All test done, many bug fixes and version bumped
  • Loading branch information
MahdiAll99 authored Apr 14, 2024
2 parents fe197af + 65ae477 commit f0a3fb2
Show file tree
Hide file tree
Showing 16 changed files with 31,998 additions and 5,957 deletions.
2 changes: 1 addition & 1 deletion MEDimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logging.getLogger(__name__).addHandler(stream_handler)

__author__ = "MEDomicsLab consortium"
__version__ = "0.9.3"
__version__ = "0.9.4"
__copyright__ = "Copyright (C) MEDomicsLab consortium"
__license__ = "GNU General Public License 3.0"
__maintainer__ = "MAHDI AIT LHAJ LOUTFI"
Expand Down
2 changes: 1 addition & 1 deletion MEDimage/learning/DataCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def cut_off_missing_per_sample(self, var_of_type: List[str], missing_cutoff : fl
"""
# Initialization
n_observation, n_features = self.df_features.shape
empty_vec = np.zeros(n_observation, dtype=np.int)
empty_vec = np.zeros(n_observation, dtype=int)
data = self.df_features[var_of_type]
empty_vec += data.isna().sum(axis=1).values

Expand Down
7 changes: 5 additions & 2 deletions MEDimage/wrangling/DataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ def __associate_rt_stuct(self) -> None:
"""
print('--> Associating all RT objects to imaging volumes')
n_rs = len(self.__dicom.stack_path_rs)
self.__dicom.stack_series_rs = list(dict.fromkeys(self.__dicom.stack_series_rs))
if n_rs:
for i in trange(0, n_rs):
try: # PUT ALL THE DICOM PATHS WITH THE SAME UID IN THE SAME PATH LIST
self.__dicom.stack_series_rs = list(set(self.__dicom.stack_series_rs))
try:
# PUT ALL THE DICOM PATHS WITH THE SAME UID IN THE SAME PATH LIST
ind_series_id = self.__find_uid_cell_index(
self.__dicom.stack_series_rs[i],
self.__dicom.cell_series_id)
Expand Down Expand Up @@ -274,6 +275,8 @@ def __read_all_dicoms(self) -> None:
except:
frame_uid = info.FrameOfReferenceUID
self.__dicom.stack_frame_rs += [frame_uid]
else:
print("Modality not supported: ", info.Modality)

except Exception as e:
print(f'Error while reading: {file}, error: {e}\n')
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- nibabel
- pandas<2.0.0
- pillow
- pydicom<2.0.0
- pydicom>1.2.0, <=1.3.0
- pywavelets
- scikit-image
- scipy
Expand Down
188 changes: 58 additions & 130 deletions notebooks/demo/Glioma-Demo.ipynb

Large diffs are not rendered by default.

114 changes: 79 additions & 35 deletions notebooks/ibsi/ibsi1p1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@
"execution_count": 1,
"id": "98c17c3c",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PyCUDA is not installed. Please install it to use the textural filters.\n"
]
}
],
"source": [
"import os\n",
"import sys\n",
"\n",
"MODULE_DIR = os.path.dirname(os.path.abspath('../MEDimage/'))\n",
"sys.path.append(os.path.dirname(MODULE_DIR))\n",
"\n",
"from copy import deepcopy\n",
"from pathlib import Path\n",
"\n",
Expand Down Expand Up @@ -145,9 +150,7 @@
"cell_type": "code",
"execution_count": 3,
"id": "c7ae2418",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -161,7 +164,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 2/2 [00:00<00:00, 59918.63it/s]\n"
"100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:00<00:00, 52265.47it/s]\n"
]
},
{
Expand All @@ -176,7 +179,9 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 1/1 [00:00<00:00, 456.60it/s]"
" 0%| | 0/2 [00:00<?, ?it/s]WARNING:root:The patient ID of the following file: FIG61__SEG.CTscan.npy does not respect the MEDimage naming convention 'study-institution-id' (Ex: Glioma-TCGA-001)\n",
"WARNING:root:The patient ID of the following file: FIG61__SEG.CTscan.npy does not respect the MEDimage naming convention 'study-institution-id' (Ex: Glioma-TCGA-001)\n",
"100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 138.29it/s]"
]
},
{
Expand Down Expand Up @@ -283,6 +288,7 @@
" mask_int=roi_obj_int.data, \n",
" mask_morph=roi_obj_morph.data,\n",
" res=MEDinstance.params.process.scale_non_text,\n",
" intensity_type=\"definite\"\n",
" )"
]
},
Expand All @@ -307,7 +313,8 @@
"local_intensity = MEDimage.biomarkers.local_intensity.extract_all(\n",
" img_obj=vol_obj.data,\n",
" roi_obj=roi_obj_int.data,\n",
" res=MEDinstance.params.process.scale_non_text)"
" res=MEDinstance.params.process.scale_non_text,\n",
" intensity_type=\"definite\")"
]
},
{
Expand All @@ -330,10 +337,49 @@
"outputs": [],
"source": [
"stats = MEDimage.biomarkers.stats.extract_all(\n",
" vol=vol_int_re\n",
" vol=vol_int_re,\n",
" intensity_type=\"definite\"\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "ed068427-0823-4788-ab43-dee44f728fe8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Fstat_mean': 2.1486487,\n",
" 'Fstat_var': 3.0454712,\n",
" 'Fstat_skew': 1.0838206041847196,\n",
" 'Fstat_kurt': -0.3546205634536057,\n",
" 'Fstat_median': 1.0,\n",
" 'Fstat_min': 1.0,\n",
" 'Fstat_P10': 1.0,\n",
" 'Fstat_P90': 4.0,\n",
" 'Fstat_max': 6.0,\n",
" 'Fstat_iqr': 3.0,\n",
" 'Fstat_range': 5.0,\n",
" 'Fstat_mad': 1.5522282,\n",
" 'Fstat_rmad': 1.1138338,\n",
" 'Fstat_medad': 1.1486486,\n",
" 'Fstat_cov': 0.8121978,\n",
" 'Fstat_qcod': 0.6,\n",
" 'Fstat_energy': 567.0,\n",
" 'Fstat_rms': 2.7680612}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stats"
]
},
{
"cell_type": "markdown",
"id": "60a1bb76",
Expand All @@ -347,7 +393,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"id": "e9e53184",
"metadata": {},
"outputs": [],
Expand All @@ -369,7 +415,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"id": "9fc60011",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -409,7 +455,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"id": "5bc89af2",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -440,7 +486,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"id": "b1ba460c",
"metadata": {},
"outputs": [],
Expand All @@ -464,7 +510,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"id": "ffc856b0",
"metadata": {},
"outputs": [],
Expand All @@ -487,7 +533,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"id": "f3ab15dd",
"metadata": {
"scrolled": true
Expand All @@ -511,7 +557,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"id": "96a026c2",
"metadata": {},
"outputs": [],
Expand All @@ -534,7 +580,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"id": "18ea2f75",
"metadata": {},
"outputs": [],
Expand All @@ -557,7 +603,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"id": "c7b48e08",
"metadata": {},
"outputs": [],
Expand All @@ -577,7 +623,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"id": "0169e310",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -607,11 +653,9 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 19,
"id": "b50a025e",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -642,10 +686,10 @@
" \"Fmorph_a_dens_ombb\": 0.8662290845560473,\n",
" \"Fmorph_v_dens_aee\": 1.172817247682943,\n",
" \"Fmorph_a_dens_aee\": 1.3551287345086926,\n",
" \"Fmorph_v_dens_mvee\": 0.43676680502143267,\n",
" \"Fmorph_a_dens_mvee\": 0.7077858057685694,\n",
" \"Fmorph_v_dens_conv_hull\": 0.960852043753598,\n",
" \"Fmorph_a_dens_conv_hull\": 1.0328688432280573,\n",
" \"Fmorph_v_dens_mvee\": 0.4487938537177223,\n",
" \"Fmorph_a_dens_mvee\": 0.6963256023315707,\n",
" \"Fmorph_v_dens_conv_hull\": 0.9608520437535985,\n",
" \"Fmorph_a_dens_conv_hull\": 1.032868843228057,\n",
" \"Fmorph_integ_int\": 1195.3649150530498,\n",
" \"Fmorph_moran_i\": [],\n",
" \"Fmorph_geary_c\": []\n",
Expand All @@ -670,8 +714,8 @@
" \"Fstat_max\": 6.0,\n",
" \"Fstat_iqr\": 3.0,\n",
" \"Fstat_range\": 5.0,\n",
" \"Fstat_mad\": 1.5522279739379883,\n",
" \"Fstat_rmad\": 1.1138339042663574,\n",
" \"Fstat_mad\": 1.5522282123565674,\n",
" \"Fstat_rmad\": 1.1138337850570679,\n",
" \"Fstat_medad\": 1.1486486196517944,\n",
" \"Fstat_cov\": 0.8121978044509888,\n",
" \"Fstat_qcod\": 0.6,\n",
Expand All @@ -693,8 +737,8 @@
" \"Fih_mode\": 1,\n",
" \"Fih_iqr\": 3.0,\n",
" \"Fih_range\": 5.0,\n",
" \"Fih_mad\": 1.5522279739379883,\n",
" \"Fih_rmad\": 1.1138339042663574,\n",
" \"Fih_mad\": 1.5522282123565674,\n",
" \"Fih_rmad\": 1.1138337850570679,\n",
" \"Fih_medad\": 1.1486486196517944,\n",
" \"Fih_cov\": 0.8121978044509888,\n",
" \"Fih_qcod\": 0.6,\n",
Expand Down Expand Up @@ -725,7 +769,7 @@
" \"Fcm_joint_var\": 3.132460960144601,\n",
" \"Fcm_joint_entr\": 2.5738963770752696,\n",
" \"Fcm_diff_avg\": 1.3795066413662238,\n",
" \"Fcm_diff_var\": 3.2146084852500096,\n",
" \"Fcm_diff_var\": 3.21460848525001,\n",
" \"Fcm_diff_entr\": 1.6408766743670586,\n",
" \"Fcm_sum_avg\": 4.297912713472486,\n",
" \"Fcm_sum_var\": 7.412196781754876,\n",
Expand Down Expand Up @@ -873,7 +917,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit f0a3fb2

Please sign in to comment.