Skip to content

Commit

Permalink
Merge pull request #15 from mjt320/develop
Browse files Browse the repository at this point in the history
roi_measure modified to generate more ROI statistics
  • Loading branch information
mjt320 authored Oct 16, 2024
2 parents ebd4dc7 + 2c32049 commit e6cf0f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Most functionality is demonstrated in Jupyter notebook format in ./demo
---

### Updates
Release 1.1.0 - *roi_measure* modified to generate more ROI statistics
Release 1.0.3 - Add exception handling for some zero/negative inputs.
Release 1.0.2 - Changed AIF interpolation method to linear to further reduce oscillations.
Release 1.0.1 - Changed AIF interpolation method to avoid oscillations. Added demo notebook on interpolation.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sepal"
version = "1.0.3"
version = "1.1.0"
description = "Quantitative MRI processing"
readme = "README.md"
authors = [{ name = "Michael Thrippleton", email = "[email protected]" }]
Expand Down
21 changes: 14 additions & 7 deletions src/sepal/utils/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def roi_measure(image, mask_image):
mask_image (str, ndarray): Mask image.
Returns:
dict{'mean': mean, 'median': median, 'sd': sd}
mean, median and sd (float, ndarray): statistics for masked
dict{'mean': mean, 'median': median, 'sd': sd, 'min': min, 'max': max, 'pct25': pct25, 'pct75': pct75}
mean, median, sd, min, max, 25th percentile and 75th percentile (float, ndarray): statistics for masked
voxels. For input data with one more dimension than the mask
image (e.g. a time series), a 1D array of floats is returned.
"""
Expand All @@ -95,9 +95,16 @@ def roi_measure(image, mask_image):

# measure statistics for masked voxels
masked_voxels = data_2d[mask_1d == 1, :]
stats = [(np.nanmean(m_d), np.nanmedian(m_d), np.nanstd(m_d))
stats = [(np.nanmean(m_d), np.nanmedian(m_d), np.nanstd(m_d), np.nanmin(m_d), np.nanmax(m_d),
np.percentile(m_d, 25), np.percentile(m_d, 75))
for m_d in masked_voxels.transpose()]
mean, median, sd = zip(*stats)

return {'mean': np.squeeze(mean), 'median': np.squeeze(median),
'sd': np.squeeze(sd)}
mean, median, sd, mini, maxi, pct25, pct75 = zip(*stats)

return {'mean': np.squeeze(mean),
'median': np.squeeze(median),
'sd': np.squeeze(sd),
'min': np.squeeze(mini),
'max': np.squeeze(maxi),
'pct25': np.squeeze(pct25),
'pct75': np.squeeze(pct75)
}

0 comments on commit e6cf0f5

Please sign in to comment.