Skip to content

Commit

Permalink
Work on Perdsc pipeline #80
Browse files Browse the repository at this point in the history
	- Validate the 2 first pipelines (1_spatial_preprocessing and 2_spatial_mask)
	- work on Make_AIF brick
  • Loading branch information
servoz committed Jun 27, 2024
1 parent 810ca51 commit 82f52ee
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mia_processes/bricks/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1852,10 +1852,10 @@ def load_nii(self, file_path, scaled=True, matlab_like=False):
def run_process_mia(self):
"""Dedicated to the process launch step of the brick."""
super(Make_AIF, self).run_process_mia()
header, data = self.load_nii(self.func_file, False, False)
header, data = self.load_nii(self.func_file, False, True)
# TODO: Perhaps we should do here a test to find out whether it's a
# 4D or a 3D? using a try statement ?
ncol, nrow, nslices, ndynamics = header.get_data_shape()
ncol, nrow, nslices, ndynamics = data.shape
# TODO: Do we really need thres?
thres = np.zeros(nslices)

Expand Down Expand Up @@ -1888,7 +1888,15 @@ def run_process_mia(self):
roi &= ~noisy
# calculation of peak heights
base_line = min_val = np.zeros((ncol, nrow, nslices))
base_line[roi] = np.mean(data[..., 1:6][roi], axis=1)
# Replicate the roi array ndynamics times along the 4th dimension
roi_replicated = np.repeat(roi[:, :, :, np.newaxis], ndynamics, axis=3)
# Apply the mask to data
masked_data = data[roi_replicated].reshape(-1, ndynamics)
# Calculate the mean along the second axis
# (ignoring the first frame, so use frames 2-6)
mean_values = np.mean(masked_data[:, 1:6], axis=1)
# Assign the mean values to base_line at the positions of roi
base_line[roi] = mean_values
min_val[roi] = np.min(data[roi], axis=1)
delta_base_min = base_line - min_val
# calculation of peak widths
Expand Down

0 comments on commit 82f52ee

Please sign in to comment.