From 1e99ccc9ceb724f2b8ad0e55315fc9a8162ce92a Mon Sep 17 00:00:00 2001
From: sharoncy <s.c.yates@medisin.uio.no>
Date: Fri, 12 May 2023 14:08:16 +0200
Subject: [PATCH] Prep for reading flat files

---
 PyNutil/counting_and_load.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/PyNutil/counting_and_load.py b/PyNutil/counting_and_load.py
index 8e4887b..7805863 100644
--- a/PyNutil/counting_and_load.py
+++ b/PyNutil/counting_and_load.py
@@ -55,3 +55,13 @@ def PixelCountPerRegion(labelsDict, label_colours):
     df_counts_per_label_name = pd.DataFrame(new_rows)
     return df_counts_per_label_name
 
+
+# import flat files, count pixels per label, np.unique... etc. nitrc.org/plugins/mwiki/index.php?title=visualign:Deformation
+"""
+   base=slice["filename"][:-4]
+   
+   import struct
+   with open(base+".flat","rb") as f:
+       b,w,h=struct.unpack(">BII",f.read(9))
+       data=struct.unpack(">"+("xBH"[b]*(w*h)),f.read(b*w*h))
+"""
-- 
GitLab