Skip to content

Commit e6cf0f5

Browse files
authored
Merge pull request #15 from mjt320/develop
roi_measure modified to generate more ROI statistics
2 parents ebd4dc7 + 2c32049 commit e6cf0f5

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Most functionality is demonstrated in Jupyter notebook format in ./demo
4242
---
4343

4444
### Updates
45+
Release 1.1.0 - *roi_measure* modified to generate more ROI statistics
4546
Release 1.0.3 - Add exception handling for some zero/negative inputs.
4647
Release 1.0.2 - Changed AIF interpolation method to linear to further reduce oscillations.
4748
Release 1.0.1 - Changed AIF interpolation method to avoid oscillations. Added demo notebook on interpolation.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "sepal"
9-
version = "1.0.3"
9+
version = "1.1.0"
1010
description = "Quantitative MRI processing"
1111
readme = "README.md"
1212
authors = [{ name = "Michael Thrippleton", email = "mjt320@googlemail.com" }]

src/sepal/utils/imaging.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def roi_measure(image, mask_image):
7676
mask_image (str, ndarray): Mask image.
7777
7878
Returns:
79-
dict{'mean': mean, 'median': median, 'sd': sd}
80-
mean, median and sd (float, ndarray): statistics for masked
79+
dict{'mean': mean, 'median': median, 'sd': sd, 'min': min, 'max': max, 'pct25': pct25, 'pct75': pct75}
80+
mean, median, sd, min, max, 25th percentile and 75th percentile (float, ndarray): statistics for masked
8181
voxels. For input data with one more dimension than the mask
8282
image (e.g. a time series), a 1D array of floats is returned.
8383
"""
@@ -95,9 +95,16 @@ def roi_measure(image, mask_image):
9595

9696
# measure statistics for masked voxels
9797
masked_voxels = data_2d[mask_1d == 1, :]
98-
stats = [(np.nanmean(m_d), np.nanmedian(m_d), np.nanstd(m_d))
98+
stats = [(np.nanmean(m_d), np.nanmedian(m_d), np.nanstd(m_d), np.nanmin(m_d), np.nanmax(m_d),
99+
np.percentile(m_d, 25), np.percentile(m_d, 75))
99100
for m_d in masked_voxels.transpose()]
100-
mean, median, sd = zip(*stats)
101-
102-
return {'mean': np.squeeze(mean), 'median': np.squeeze(median),
103-
'sd': np.squeeze(sd)}
101+
mean, median, sd, mini, maxi, pct25, pct75 = zip(*stats)
102+
103+
return {'mean': np.squeeze(mean),
104+
'median': np.squeeze(median),
105+
'sd': np.squeeze(sd),
106+
'min': np.squeeze(mini),
107+
'max': np.squeeze(maxi),
108+
'pct25': np.squeeze(pct25),
109+
'pct75': np.squeeze(pct75)
110+
}

0 commit comments

Comments
 (0)