Skip to content

Commit

Permalink
Merge pull request #176 from scottclowe/bug_mean-float16-tiff
Browse files Browse the repository at this point in the history
BUG: Inaccurate means for float16 TIFFs
  • Loading branch information
scottclowe committed Jun 16, 2021
2 parents 3ade23b + e33a06e commit fd9d282
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions fissa/extraction.py
Expand Up @@ -200,7 +200,7 @@ def getmean(data):
numpy.ndarray
y by x array for the mean values
"""
return data.mean(axis=0)
return data.mean(axis=0, dtype=np.float64)

@staticmethod
def rois2masks(rois, data):
Expand Down Expand Up @@ -270,7 +270,7 @@ def extracttraces(data, masks):
# loop over masks
for i in range(nrois): # for masks
# get mean data from mask
out[i, :] = data[:, masks[i]].mean(axis=1)
out[i, :] = data[:, masks[i]].mean(axis=1, dtype=np.float64)

return out

Expand Down Expand Up @@ -317,7 +317,7 @@ def getmean(data):
# We don't load the entire image into memory at once, because
# it is likely to be rather large.
# Initialise holding array with zeros
avg = np.zeros(data.size[::-1])
avg = np.zeros(data.size[::-1], dtype=np.float64)

# Make sure we seek to the first frame before iterating. This is
# because the Iterator outputs the value for the current frame for
Expand Down Expand Up @@ -411,6 +411,6 @@ def extracttraces(data, masks):
# loop over masks
for i in range(nrois):
# get mean data from mask
out[i, f] = np.mean(curframe[masks[i]])
out[i, f] = np.mean(curframe[masks[i]], dtype=np.float64)

return out
2 changes: 1 addition & 1 deletion fissa/tests/test_extraction.py
Expand Up @@ -244,7 +244,7 @@ def multiframe_mean_tester(base_fname, dtype, datahandler):
]
)
expected = get_dtyped_expected(expected, dtype)
expected = np.mean(expected, axis=0)
expected = np.mean(expected, dtype=np.float64, axis=0)
fname = os.path.join(
RESOURCES_DIR,
base_fname + "_{}.tif".format(dtype)
Expand Down

0 comments on commit fd9d282

Please sign in to comment.