Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Adds closing parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
teresamg committed Mar 29, 2023
1 parent c941aaa commit 0e07b2f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/eddymotion/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,23 @@ def plot_carpet(

nii_data_div_b0 = dw_data / bzero[..., np.newaxis]

sort_inds = (
np.argsort(gtab.bvals[~gtab.b0s_mask] if sort_by_bval
sort_inds = np.argsort(
gtab.bvals[~gtab.b0s_mask]
if sort_by_bval
else np.arange(len(gtab.bvals[~gtab.b0s_mask]))
)
nii_data_div_b0 = nii_data_div_b0[..., sort_inds]

# Reshape
nii_data_reshaped = nii_data_div_b0.reshape(-1, nii_data_div_b0.shape[-1])

if brain_mask is not None:
brain_mask_data = np.asanyarray(brain_mask.dataobj, dtype=np.int16)
if segmentation is not None:
segmentation_data = np.asanyarray(segmentation.dataobj, dtype=np.int16)

# Apply mask
brain_mask_reshaped = brain_mask_data.reshape(-1)
nii_data_masked = nii_data_reshaped[brain_mask_reshaped > 0, :]
brain_mask_masked = brain_mask_reshaped[brain_mask_reshaped > 0]
segmentation_reshaped = segmentation_data.reshape(-1)
nii_data_masked = nii_data_reshaped[segmentation_reshaped > 0, :]
segmentation_masked = segmentation_reshaped[segmentation_reshaped > 0]

if segment_labels is not None:
segments = dict()
Expand All @@ -351,7 +352,7 @@ def plot_carpet(
indices = np.array([], dtype=int)
for ii in segment_labels[label]:
indices = np.concatenate(
[indices, np.where(brain_mask_masked == ii)[0]]
[indices, np.where(segmentation_masked == ii)[0]]
)
segments[label] = indices

Expand Down

0 comments on commit 0e07b2f

Please sign in to comment.