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
12 changes: 10 additions & 2 deletions Rhapso/data_prep/xml_to_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ def parse_image_loader_zarr(self, root):
for il in root.findall(".//ImageLoader/zgroups/zgroup"):
view_setup = il.get("setup")
timepoint = il.get("timepoint")
file_path = il.find("path").text if il.find("path") is not None else None
channel = file_path.split("_ch_", 1)[1].split(".ome.zarr", 1)[0]
file_path = il.get("path")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update parse_image_loader_zarr() to properly handle bigstitcher xml conventions, and channel default when not in filename

if file_path is None:
element_string = ET.tostring(il, encoding='unicode')
raise ValueError(f"zgroup element missing 'path' attribute: {element_string}")

# default to channel 0 if not parseable from the path name
try:
channel = file_path.split("_ch_", 1)[1].split(".ome.zarr", 1)[0]
except (IndexError, AttributeError):
channel = 0

image_loader_data.append(
{
Expand Down
4 changes: 3 additions & 1 deletion Rhapso/detection/advanced_refinement.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def filter(self):
lb = row['lower_bound']
ub = row['upper_bound']
if vid == view_id:
to_process_interval = (lb, ub)

ub_inclusive = (ub[0]+1, ub[1]+1, ub[2]+1)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interval needs to use inclusive coordinates for upper bound, so that it is compatible with block_interval coordinates when calling self.contain()

to_process_interval = (lb, ub_inclusive)
ips_block = []
intensities_block = []

Expand Down
8 changes: 5 additions & 3 deletions Rhapso/detection/overlap_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import s3fs
import dask.array as da
import math
import os

"""
Overlap Detection figures out where image tile overlap.
Expand Down Expand Up @@ -50,7 +51,7 @@ def load_image_metadata(self, file_path):
return self.image_shape_cache[file_path]

if self.file_type == 'zarr':
s3 = s3fs.S3FileSystem(anon=False)
s3 = s3fs.S3FileSystem(anon=True)
store = s3fs.S3Map(root=file_path, s3=s3)
zarr_array = zarr.open(store, mode='r')
dask_array = da.from_zarr(zarr_array)
Expand Down Expand Up @@ -246,7 +247,8 @@ def find_overlapping_area(self):
all_intervals = []
if self.file_type == 'zarr':
level, leftovers = self.choose_zarr_level()
dim_base = self.load_image_metadata(self.prefix + row_i['file_path'] + f'/{0}')

dim_base = self.load_image_metadata(os.path.join(self.prefix, row_i['file_path']))

# isotropic pyramid
s = float(2 ** level)
Expand All @@ -256,7 +258,7 @@ def find_overlapping_area(self):
_, dsxy, dsz = leftovers

elif self.file_type == 'tiff':
dim_base = self.load_image_metadata(self.prefix + row_i['file_path'])
dim_base = self.load_image_metadata(os.path.join(self.prefix, row_i['file_path']))
mipmap_of_downsample = self.create_mipmap_transform()
dsxy, dsz = self.dsxy, self.dsz
level = None
Expand Down
3 changes: 1 addition & 2 deletions Rhapso/split_dataset/compute_grid_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ def closest_larger_long_divisible_by(self, a, b):

return int(a + b - (a % b))

def find_min_step_size(self):
def find_min_step_size(self, lowest_resolution=(1.0, 1.0, 1.0)):
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to allow for blocks to be created at 1.0 pixel resolution (previously was limited to blocksizes of powers of 64)

"""
Compute the minimal integer step size per axis (X,Y,Z) that is compatible with the chosen lowest resolution
"""
lowest_resolution=(64.0, 64.0, 64.0)
min_step_size = [1, 1, 1]

for d, r in enumerate(lowest_resolution):
Expand Down
9 changes: 6 additions & 3 deletions Rhapso/split_dataset/save_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,12 @@ def _norm_id(raw):
outer_timepoints = ch
break
if outer_timepoints is None:
outer_timepoints = ET.Element('Timepoints', {'type': 'pattern'})
ip = ET.SubElement(outer_timepoints, 'integerpattern')
ip.text = "0"
tps = sorted({int(v['old_view'][0]) for v in self.self_definition if v['old_view'][0] is not None})
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Determine timepoints integer range from pre-split views

first_tp = str(tps[0]) if tps else "0"
last_tp = str(tps[-1]) if tps else "0"
outer_timepoints = ET.Element('Timepoints', {'type': 'range'})
ET.SubElement(outer_timepoints, 'first').text = first_tp
ET.SubElement(outer_timepoints, 'last').text = last_tp
# place right after ViewSetups
children = list(outer_seq)
insert_idx = children.index(view_setups) + 1 if view_setups in children else len(children)
Expand Down
Loading