Skip to content

Commit

Permalink
Added docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
etpeterson committed Oct 18, 2024
1 parent 71924b2 commit 2a46909
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions WrapImage/nifti_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ def loop_over_first_n_minus_1_dimensions(arr):
yield idx, flat_view

def generate_data(data, bvals, b0_indices, groups, total_iteration):
"""
Generates data samples for a multiprocess fitting
Args:
data: The raw data to be sampled
bvals: The bvalues
b0_indices: The b0 indices in the data
groups: The group indices in the data
total_iterations: The total number of iterations to generate
Yields:
A tuple containing matching: data, bvalues, and b0_indices
"""
num_directions = groups.shape[1]
data = data.reshape(total_iteration, -1)
for idx in range(total_iteration):
Expand All @@ -33,6 +46,16 @@ def generate_data(data, bvals, b0_indices, groups, total_iteration):
yield (data[idx, groups[:, dir]].flatten(), bvals[:, groups[:, dir]].ravel(), b0_indices[:, groups[:, dir]].ravel())

def osipi_fit(fitfunc, data_bvals):
"""
Fit the data using the provided fit function
Args:
fitfunc: The fit function
data_bvals: The tuple of data, bvals, and b0_indices
Returns:
The fitted values
"""
data, bvals, b0_indices = data_bvals
data = normalize_series(data, b0_indices)
# print(f'data.shape {data.shape} data {data} bvals {bvals}')
Expand Down

0 comments on commit 2a46909

Please sign in to comment.