Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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]:
# h5 file is marked as not being related to novisim. This is used in later checks.
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"]:
implant_threshold_u16 = implant_threshold_u16_novisim

if args.verbose >= 2: print(f"""
Expand Down
3 changes: 2 additions & 1 deletion src/processing_steps/0750_bone_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
implant_file = h5py.File(f"{hdf5_root}/masks/{args.sample_scale}x/{args.sample}.h5",'r')
implant = implant_file["implant/mask"][:].astype(np.uint8)
voxel_size = implant_file["implant"].attrs["voxel_size"]
novisimflag = implant_file.attrs["novisim"]
implant_file.close()

nz, ny, nx = implant.shape
Expand Down Expand Up @@ -132,7 +133,7 @@
del front_part
if args.plotting: plot_middle_planes(bone_mask1, plotting_dir, 'implant-bone1-sanity', verbose=args.verbose)

if 'novisim' in args.sample:
if novisimflag:
closing_diameter, opening_diameter, implant_dilate_diameter = 400, 300, 15 # micrometers
else:
closing_diameter, opening_diameter, implant_dilate_diameter = 400, 300, 5 # micrometers
Expand Down
3 changes: 2 additions & 1 deletion src/processing_steps/1000_compute_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ def run_out_of_core(sample, scale=1, chunk_size=128, z_offset=0, n_chunks=0,
if args.verbose >= 1: print(f"Loaded {gb:.02f} GB in {end-start} ({gb / (end-start).total_seconds()} GB/s)")
verify_and_benchmark(voxels, field, plotting_dir, args.voxel_bins // args.sample_scale, args.benchmark_runs, args.verbose)
else:
if 'novisim' in args.sample:
h5meta = h5py.File(f'{hdf5_root}/hdf5-byte/msb/{args.sample}.h5', 'r')
if h5meta["novisim"]:
implant_threshold = 40000
else:
implant_threshold = implant_threshold_u16
Expand Down