Skip to content

Commit

Permalink
Merge pull request #27 from MahdiAll99/dev
Browse files Browse the repository at this point in the history
Updated display methods
  • Loading branch information
MahdiAll99 authored Aug 24, 2022
2 parents 478b39c + 32243b4 commit 653d997
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions MEDimage/MEDimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,11 +1142,12 @@ def get_indexes_by_roi_name(self, roi_name : str) -> np.ndarray:
roi_volume[self.ROI.get_indexes(roi_name_key)] = 1
return roi_volume.reshape(self.volume.data.shape)

def display(self, _slice: int = None) -> None:
def display(self, _slice: int = None, roi: Union[str, int] = 0) -> None:
"""Displays slices from imaging data with the ROI contour in XY-Plane.
Args:
_slice (int, optional): Index of the slice you want to plot.
roi (Union[str, int], optional): ROI name or index. If not specified will use the first ROI.
Returns:
None.
Expand All @@ -1157,15 +1158,15 @@ def display(self, _slice: int = None) -> None:
i = np.arange(0, size_m[0])
j = np.arange(0, size_m[1])
k = np.arange(0, size_m[2])
ind_mask = np.nonzero(self.get_roi_from_indexes(0))
ind_mask = np.nonzero(self.get_roi_from_indexes(roi))
J, I, K = np.meshgrid(i, j, k, indexing='ij')
I = I[ind_mask]
J = J[ind_mask]
K = K[ind_mask]
slices = np.unique(K)

vol_data = self.volume.data.swapaxes(0, 1)[:, :, slices]
roi_data = self.get_roi_from_indexes(0).swapaxes(0, 1)[:, :, slices]
roi_data = self.get_roi_from_indexes(roi).swapaxes(0, 1)[:, :, slices]

rows = int(np.round(np.sqrt(len(slices))))
columns = int(np.ceil(len(slices) / rows))
Expand Down Expand Up @@ -1217,11 +1218,12 @@ def display(self, _slice: int = None) -> None:

plt.show()

def display_process(self, _slice: int = None) -> None:
def display_process(self, _slice: int = None, roi: Union[str, int] = 0) -> None:
"""Displays slices from imaging data with the ROI contour in XY-Plane.
Args:
_slice (int, optional): Index of the slice you want to plot.
roi (Union[str, int], optional): ROI name or index. If not specified will use the first ROI.
Returns:
None.
Expand All @@ -1232,15 +1234,15 @@ def display_process(self, _slice: int = None) -> None:
i = np.arange(0, size_m[0])
j = np.arange(0, size_m[1])
k = np.arange(0, size_m[2])
ind_mask = np.nonzero(self.get_roi_from_indexes(0))
ind_mask = np.nonzero(self.get_roi_from_indexes(roi))
J, I, K = np.meshgrid(j, i, k, indexing='ij')
I = I[ind_mask]
J = J[ind_mask]
K = K[ind_mask]
slices = np.unique(K)

vol_data = self.volume_process.data.swapaxes(0, 1)[:, :, slices]
roi_data = self.get_roi_from_indexes(0).swapaxes(0, 1)[:, :, slices]
roi_data = self.get_roi_from_indexes(roi).swapaxes(0, 1)[:, :, slices]

rows = int(np.round(np.sqrt(len(slices))))
columns = int(np.ceil(len(slices) / rows))
Expand Down

0 comments on commit 653d997

Please sign in to comment.