GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 598c0d7e authored by Thomas Vincent's avatar Thomas Vincent

code style

parent aaa91dda
......@@ -347,7 +347,7 @@ def _fit_process(index,
qspace_f,
fit_type=FitTypes.GAUSSIAN,
background_type=BackgroundTypes.NONE,
roiIndices=None):
roi_indices=None):
"""Run fit processing.
It loads a QSpace, extracts a ROI from it, project to axes,
......@@ -360,7 +360,7 @@ def _fit_process(index,
:param FitTypes fit_type: The kind of fit to perform
:param BackgroundTypes background_type:
The kind of background subtraction to perform
:param Union[List[List[int]],None] roiIndices:
:param Union[List[List[int]],None] roi_indices:
Optional QSpace ROI start:end in the 3 dimensions
:return: Fit results as a list of results for dim0, dim1 and dim2
:rtype: List[List[Union[float,bool]]]
......@@ -378,15 +378,15 @@ def _fit_process(index,
qspace = qspace_h5.qspace_slice(index)
# apply Qspace ROI
if roiIndices is not None:
dim0Slice = slice(roiIndices[0][0], roiIndices[0][1], 1)
dim1Slice = slice(roiIndices[1][0], roiIndices[1][1], 1)
dim2Slice = slice(roiIndices[2][0], roiIndices[2][1], 1)
if roi_indices is not None:
dim0_slice = slice(roi_indices[0][0], roi_indices[0][1], 1)
dim1_slice = slice(roi_indices[1][0], roi_indices[1][1], 1)
dim2_slice = slice(roi_indices[2][0], roi_indices[2][1], 1)
axes = [axis[roi] for axis, roi in
zip(axes, (dim0Slice, dim1Slice, dim2Slice))]
hits = hits[dim0Slice, dim1Slice, dim2Slice]
qspace = qspace[dim0Slice, dim1Slice, dim2Slice]
zip(axes, (dim0_slice, dim1_slice, dim2_slice))]
hits = hits[dim0_slice, dim1_slice, dim2_slice]
qspace = qspace[dim0_slice, dim1_slice, dim2_slice]
# Normalize with hits and project to axes
projections = project(qspace, hits)
......@@ -396,12 +396,16 @@ def _fit_process(index,
for array in projections:
array -= background_estimation(background_type, array)
# Fit/COM
fit = {FitTypes.CENTROID: centroid,
FitTypes.GAUSSIAN: gaussian_fit}[fit_type]
result = [fit(axis, values) for axis, values in zip(axes, projections)]
# Select Fit/COM function
if fit_type == FitTypes.CENTROID:
fit_func = centroid
elif fit_type == FitTypes.GAUSSIAN:
fit_func = gaussian_fit
else:
raise RuntimeError("Unsupported fit type: %s" % fit_type)
return result
# Fit/COM for projections on each axes
return [fit_func(axis, signal) for axis, signal in zip(axes, projections)]
# Center of mass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment