aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--README.md63
-rwxr-xr-xbuildall.sh29
-rwxr-xr-xload_c_data.py27
-rwxr-xr-xrun.sh4
5 files changed, 121 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 9ef52ff..8284f6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,12 @@
# Build files
build/
+# Virtual Environment
+.venv/
+
# Data files
data/
output/
+# pixi environments
+.pixi/*
+!.pixi/config.toml
diff --git a/README.md b/README.md
index 2c56d27..f10e8d2 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,65 @@
** Example Usage
-```sh
-for file in data/HT-*/; do ./run.sh `basename $file`; done
+For the following labelling input structure
+```
+data/
+├── test
+│   ├── HT-A1
+│   │   ├── Label1.tif
+│   │   ├── OtherLabel.tif
+│   │   ├── NameMe.tif
+│   │   └── A1.labels.tif[4].tif
+│   └── HT-A2
+│   ├── Label.tif
+│   ├── 2.tif
+│   └── A2.tif
+└── train
+ ├── HT-B1
+ │   └── B1.labels.tif[0].tif
+ ├── HT-B2
+ │   ├── B2.tif\ [1].tif
+ │   ├── B2.tif\ [2].tif
+ │   └── B2.tif\ [3].tif
+ ├── HT-C5
+ │   ├── C5.tif\ [1].tif
+ │   ├── C5.tif\ [2].tif
+ │   └── C5.tif\ [3].tif
+ └── HT-J9
+ └── J9.tif[1].tif
```
+Simply run:
```sh
-mkdir -p output/small/
-./build/prog sample_data/small output/small/small.bin output/small/small.png
+./buildall.sh
+```
+
+To get:
+```
+output/
+├── test
+│   ├── HT-A1.bin
+│   ├── HT-A1.png
+│   ├── HT-A1_seg.npy
+│   ├── HT-A1.tif
+│   ├── HT-A2.bin
+│   ├── HT-A2.png
+│   ├── HT-A2_seg.npy
+│   └── HT-A2.tif
+└── train
+ ├── HT-B1.bin
+ ├── HT-B1.png
+ ├── HT-B1_seg.npy
+ ├── HT-B1.tif
+ ├── HT-B2.bin
+ ├── HT-B2.png
+ ├── HT-B2_seg.npy
+ ├── HT-B2.tif
+ ├── HT-C5.bin
+ ├── HT-C5.png
+ ├── HT-C5_seg.npy
+ ├── HT-C5.tif
+ ├── HT-J9.bin
+ ├── HT-J9.png
+ ├── HT-J9_seg.npy
+ └── HT-J9.tif
```
diff --git a/buildall.sh b/buildall.sh
new file mode 100755
index 0000000..7cccd23
--- /dev/null
+++ b/buildall.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+make
+
+CLEAN="t"
+
+builder() {
+ SOURCE="$1"
+ SNAME="`basename \"${SOURCE}\"`"
+ DNAME="`dirname \"${SOURCE}\"`"
+ mkdir -p ../output/${DNAME}
+ ../build/prog -s -n 8 -d ${SOURCE} -b ../output/${DNAME}/${SNAME}.bin -p ../output/${DNAME}/${SNAME}.png
+}
+
+cd data/
+for dname in */*; do
+ builder "${dname}" &
+done
+wait
+
+cd ..
+for bname in output/*/*.bin; do
+ python load_c_data.py "${bname}" &
+done
+wait
+
+if [ "${CLEAN}" = "t" ]; then
+ rm output/*/*.bin
+ rm output/*/*.png
+fi
diff --git a/load_c_data.py b/load_c_data.py
new file mode 100755
index 0000000..a3a905b
--- /dev/null
+++ b/load_c_data.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3.11
+import numpy as np
+from sys import argv
+from matplotlib import pyplot as plt
+import tifffile
+#from tqdm.std import tqdm
+
+FILE_NAME=None
+if len(argv) > 1:
+ FILE_NAME = argv[1]
+DTYPE=np.uint16
+WIDTH,HEIGHT=1920,2560
+data = np.fromfile(FILE_NAME, dtype=DTYPE)
+_im = plt.imread(FILE_NAME[:-len("bin")] + "png")
+w,h,c = _im.shape
+if w <= 4:
+ c,w,h = w,h,c
+WIDTH,HEIGHT = w,h
+labels = data.reshape(WIDTH,HEIGHT)
+
+BASE="/home/physics/cunnichr/Data/HistologyArrays/HistologyArray00/"
+NAME = FILE_NAME[-len("HT-XX.bin"):-len(".bin")]
+image = plt.imread(BASE + NAME + "/image.png")
+print(FILE_NAME[:-len("bin")] + "tif", "\n", image.transpose(2,0,1).shape, len(np.unique(labels)))
+tifffile.imwrite(FILE_NAME[:-len("bin")] + "tif", image.transpose(2,0,1)[:3,...])
+#np.savez(FILE_NAME[:-len("bin")] + ".npz", image=[], masks=labels)
+np.save(FILE_NAME[:-len(".bin")] + "_seg.npy", dict(image=image, masks=labels))
diff --git a/run.sh b/run.sh
deleted file mode 100755
index 8b9c597..0000000
--- a/run.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-SOURCE="$1"
-mkdir -p output/${SOURCE}
-./build/prog -s -n 8 -d data/${SOURCE} -b output/${SOURCE}/${SOURCE}.bin -p output/${SOURCE}/${SOURCE}.png