Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: added novisim as metadata flag for h5 files #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/py/esrf_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def esrf_edf_metadata(filename):
if (len(kv) >= 2):
meta[kv[0].strip()] = kv[1].strip()

assert meta["ByteOrder"] == "LowByteFirst"
# removing " ;"
assert meta["ByteOrder"].split()[0] == "LowByteFirst"

if (meta["DataType"] == "UnsignedShort"):
meta["NumpyType"] = np.uint16
Expand Down
2 changes: 2 additions & 0 deletions src/processing_steps/0200_generate_byte_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@

# Store metadata in both files for each subvolume scan
for h5file in [h5file_msb,h5file_lsb]:
# never a novisim tomogram at this point, but added to all *.h5 files for later checks
carljohnsen marked this conversation as resolved.
Show resolved Hide resolved
h5file.attrs["novisim"] = 0
grp_meta = h5file.create_group("metadata")
for i in range(len(subvolume_metadata)):
subvolume_info = subvolume_metadata[i]
Expand Down
1 change: 1 addition & 0 deletions src/processing_steps/0225_generate_hdf5_novisim.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
h5_msb = h5py.File(f'{output_dir}/msb/{args.sample}.h5', 'w')

for h5, tomo in [(h5_lsb, tomo_lsb), (h5_msb, tomo_msb)]:
h5.attrs["novisim"] = 1 # set flag to mark file as novisim tomogram
h5.create_dataset('subvolume_dimensions', (1,3), data=[[nz, ny, nx]], dtype=np.uint16)
h5.create_dataset('subvolume_range', (1,2,), dtype=np.float32, data=np.array([0, 65535]))
h5_tomo = h5.create_dataset('voxels', (nz, ny, nx), dtype=np.uint8, data=tomo)
Expand Down
4 changes: 3 additions & 1 deletion src/processing_steps/0600_segment_implant_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
global_vmax = np.max(h5meta['subvolume_range'][:,1])
values = np.linspace(global_vmin,global_vmax,2**16)
implant_threshold_u16 = np.argmin(np.abs(values-implant_threshold))
if 'novisim' in args.sample:

# check if chosen sample has novisim flag set in metadata
if h5meta["novisim"]:
carljohnsen marked this conversation as resolved.
Show resolved Hide resolved
implant_threshold_u16 = implant_threshold_u16_novisim

if args.verbose >= 2: print(f"""
Expand Down