Skip to content

Commit

Permalink
V0.5.1 improved metadata parsing (#12)
Browse files Browse the repository at this point in the history
* Testing new metadata parse

* Fix switch statement

* Add unit parsing
  • Loading branch information
GeekLogan authored Jan 7, 2025
1 parent b3bf7a0 commit 6098936
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ class archive_reader

auto domain = store.domain();
auto shape = domain.shape();
auto labels = domain.labels();

sizex = 0;
sizey = 0;
Expand All @@ -476,12 +477,16 @@ class archive_reader
switch(i) {
case 0: // x
sizex = dim;
break;
case 1: // y
sizey = dim;
break;
case 2: // z
sizez = dim;
break;
case 3: // c
channel_count = dim;
break;
}

i++;
Expand All @@ -499,6 +504,40 @@ class archive_reader
resy = 100;
resz = 100;

auto dim_units_result = store.dimension_units();

if (!dim_units_result.ok())
{
std::cerr << "Error reading dimension_units from TensorStore: " << store_result.status() << std::endl;
} else {
auto dim_units = dim_units_result.value();

for(size_t i = 0; i < dim_units.size(); i++) {
if(dim_units[i].has_value()) {
tensorstore::Unit u = dim_units[i].value();

// TODO Verify that unit is nm and scale properly

switch(i) {
case 0: // x
resx = u.multiplier;
break;
case 1: // y
resy = u.multiplier;
break;
case 2: // z
resz = u.multiplier;
break;
case 3: // c
// Color does not have a unit
break;
}

//std::cout << "Name: " << labels[i] << '\t' << u.to_string() << '\t' << u.base_unit << '\t' << u.multiplier << std::endl;
}
}
}

mchunkx = sizex;
mchunky = sizey;
mchunkz = sizez;
Expand Down

0 comments on commit 6098936

Please sign in to comment.