From a082f5b64a68d0dbd5ce0c32643ffb48ba744136 Mon Sep 17 00:00:00 2001
From: Constantin Pape <constantin.pape@iwr.uni-heidelberg.de>
Date: Mon, 8 Jul 2019 14:33:56 +0200
Subject: [PATCH] Update prospr segmented regions

---
 ...-6dpf-1-whole-segmented-CrypticSegment.xml | 12 +++++-----
 .../prospr-6dpf-1-whole-segmented-Head.xml    | 12 +++++-----
 .../prospr-6dpf-1-whole-segmented-PNS.xml     | 12 +++++-----
 ...prospr-6dpf-1-whole-segmented-Pygidium.xml | 12 +++++-----
 ...pr-6dpf-1-whole-segmented-RestOfAnimal.xml | 12 +++++-----
 ...rospr-6dpf-1-whole-segmented-Stomodeum.xml | 12 +++++-----
 .../prospr-6dpf-1-whole-segmented-VNC.xml     | 12 +++++-----
 make_initial_version.py                       | 22 +++++++++++++++++++
 8 files changed, 64 insertions(+), 42 deletions(-)

diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-CrypticSegment.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-CrypticSegment.xml
index 4272f85..c756b3c 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-CrypticSegment.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-CrypticSegment.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-CrypticSegment.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-Head.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-Head.xml
index 1d624ec..de6c251 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-Head.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-Head.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-Head.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-PNS.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-PNS.xml
index 2e3f4c9..fd9e36f 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-PNS.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-PNS.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-PNS.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-Pygidium.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-Pygidium.xml
index d2d0ccb..b9b4060 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-Pygidium.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-Pygidium.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-Pygidium.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-RestOfAnimal.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-RestOfAnimal.xml
index ff71c06..d97dd9d 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-RestOfAnimal.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-RestOfAnimal.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-RestOfAnimal.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-Stomodeum.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-Stomodeum.xml
index 9439922..7f409ff 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-Stomodeum.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-Stomodeum.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-Stomodeum.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/data/rawdata/prospr-6dpf-1-whole-segmented-VNC.xml b/data/rawdata/prospr-6dpf-1-whole-segmented-VNC.xml
index 5072ebd..77ea228 100644
--- a/data/rawdata/prospr-6dpf-1-whole-segmented-VNC.xml
+++ b/data/rawdata/prospr-6dpf-1-whole-segmented-VNC.xml
@@ -5,6 +5,12 @@
       <hdf5 type="relative">prospr-6dpf-1-whole-segmented-VNC.h5</hdf5>
     </ImageLoader>
     <ViewSetups>
+      <Attributes name="channel">
+        <Channel>
+          <id>1</id>
+          <name>1</name>
+        </Channel>
+      </Attributes>
       <ViewSetup>
         <id>0</id>
         <name>channel 1</name>
@@ -17,12 +23,6 @@
           <channel>1</channel>
         </attributes>
       </ViewSetup>
-      <Attributes name="channel">
-        <Channel>
-          <id>1</id>
-          <name>1</name>
-        </Channel>
-      </Attributes>
     </ViewSetups>
     <Timepoints type="range">
       <first>0</first>
diff --git a/make_initial_version.py b/make_initial_version.py
index aa993ae..f8528b2 100755
--- a/make_initial_version.py
+++ b/make_initial_version.py
@@ -2,11 +2,14 @@
 
 import os
 from shutil import copyfile
+from glob import glob
 
+import h5py
 from scripts.files import make_folder_structure
 from scripts.export import export_segmentation
 from scripts.files import make_bdv_server_file, copy_image_data, copy_misc_data
 from scripts.attributes import make_nucleus_tables, make_cell_tables
+from pybdv.converter import make_bdv
 
 
 def make_sbem_segmentations(old_folder, folder):
@@ -51,6 +54,23 @@ def make_sbem_tables(folder):
     copyfile(tissue_table_in, tissue_table_out)
 
 
+def make_prospr_region_segmentations():
+    in_prefix = '/g/arendt/EM_6dpf_segmentation/EM-Prospr/BodyPart_*.h5'
+    out_prefix = './data/rawdata/prospr-6dpf-1-whole-segmented-'
+    files = glob(in_prefix)
+    for p in files:
+        name = p.split('_')[-1][:-3]
+        o = out_prefix + name + '.h5'
+        print(p, "to", o)
+        with h5py.File(p) as f:
+            key = 't00000/s00/0/cells'
+            data = f[key][:]
+            data[data > 0] = 0
+            data[data < 0] = 255
+        make_bdv(data, o, 3 * [[2, 2, 2]],
+                 unit='micrometer', resolution=[0.5, 0.5, 0.5])
+
+
 def make_initial_version():
 
     src_folder = 'data/rawdata'
@@ -76,5 +96,7 @@ def make_initial_version():
                          os.path.join(folder, 'misc', 'bdvserver.txt'))
 
 
+
 if __name__ == '__main__':
+    # make_prospr_region_segmentations()
     make_initial_version()
-- 
GitLab