Skip to content
Snippets Groups Projects
Commit 0f3f110c authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Added and covered PatchStack dataframe with summary stats

parent ddbf2ab6
No related branches found
No related tags found
2 merge requests!69Release 2024.11.1,!68Updates for TREC pipelines
This commit is part of merge request !68. Comments created here will be created in the context of that merge request.
......@@ -3,6 +3,7 @@ import os
from pathlib import Path
import numpy as np
import pandas as pd
from skimage.io import imread, imsave
import czifile
......@@ -491,6 +492,18 @@ class PatchStack(InMemoryDataAccessor):
def shape_dict(self):
return dict(zip(('P', 'Y', 'X', 'C', 'Z'), self.data.shape))
@property
def df(self):
df = pd.DataFrame([
{
'label': i,
'area': (self.iat(i).data > 0).sum(),
'sum': self.iat(i).data.sum()
} for i in range(0, self.count)
])
df['intensity_mean'] = df['sum'] / df['area']
return df
def make_patch_stack_from_file(fpath): # interpret t-dimension as patch position
if not Path(fpath).exists():
......
......@@ -302,6 +302,9 @@ class TestPatchStackAccessor(unittest.TestCase):
self.assertEqual(acc.hw, (h, w))
self.assertEqual(acc.get_mono(channel=0).data_yxz.shape, (n, h, w, nz))
self.assertEqual(acc.get_mono(channel=0, mip=True).data_yx.shape, (n, h, w))
# intensity means are centered around half of full range
self.assertTrue(np.all(((acc.df['intensity_mean'] / acc.dtype_max) - 0.5)**2 < 1e-3))
return acc
def test_get_one_channel(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment