Skip to content

Commit

Permalink
Add multi_tiff attribute for Bruker scans
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalbakshi committed Apr 23, 2024
1 parent bf76438 commit 18d0e34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
27 changes: 16 additions & 11 deletions element_calcium_imaging/field_processing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib
import inspect
import shutil
import pathlib
from collections.abc import Callable
from datetime import datetime
Expand Down Expand Up @@ -74,7 +75,7 @@ def key_source(self):
* scan.ScanInfo.proj("nrois", "nfields")
* imaging.ProcessingParamSet.proj("processing_method")
& "task_mode = 'trigger'"
) & "nfields > 1"
) & "nfields >= 1"
ks &= "(processing_method = 'suite2p' AND nrois > 0) OR (processing_method = 'caiman' AND nrois = 0)"
return ks - imaging.Processing.proj()

Expand Down Expand Up @@ -105,9 +106,9 @@ def make(self, key):
acq_software = (scan.Scan & key).fetch1("acq_software")

field_ind = (scan.ScanInfo.Field & key).fetch("field_idx")
sampling_rate, ndepths, nchannels, nfields, nrois = (
sampling_rate, ndepths, nchannels, nfields, nrois, multi_tiff = (
scan.ScanInfo & key
).fetch1("fps", "ndepths", "nchannels", "nfields", "nrois")
).fetch1("fps", "ndepths", "nchannels", "nfields", "nrois", "multi_tiff")

if method == "caiman" and acq_software == "PrairieView":
from element_interface.prairie_view_loader import (
Expand All @@ -132,14 +133,18 @@ def make(self, key):
prepared_input_dir = output_dir.parent / "prepared_input"
prepared_input_dir.mkdir(exist_ok=True)

image_files = [
PVmeta.write_single_bigtiff(
plane_idx=plane_idx,
channel=channel,
output_dir=prepared_input_dir,
caiman_compatible=True,
)
]
if multi_tiff:
shutil.copy(find_full_path(scan.get_imaging_root_data_dir(), image_file), prepared_input_dir)
image_files = [prepared_input_dir / pathlib.Path(image_file).name]
else:
image_files = [
PVmeta.write_single_bigtiff(
plane_idx=plane_idx,
channel=channel,
output_dir=prepared_input_dir,
caiman_compatible=True,
)
]

field_processing_tasks.append(
{
Expand Down
3 changes: 3 additions & 0 deletions element_calcium_imaging/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class ScanInfo(dj.Imported):
scan_datetime (datetime, optional): Datetime of the scan.
scan_duration (float, optional): Duration of the scan (s).
bidirectional_z (bool, optional): True = bidirectional z-scan.
multi_tiff (bool): True = multi-tiff scan. Relevant for Bruker PrairieView.
"""

definition = """ # General data about the resoscans/mesoscans from header
Expand All @@ -234,6 +235,7 @@ class ScanInfo(dj.Imported):
scan_datetime=null : datetime # datetime of the scan
scan_duration=null : float # (seconds) duration of the scan
bidirectional_z=null : boolean # true = bidirectional z-scan
multi_tiff=True : boolean # true = multi-tiff scan. Relevant for Bruker PrairieView
"""

class Field(dj.Part):
Expand Down Expand Up @@ -547,6 +549,7 @@ def estimate_nd2_scan_duration(nd2_scan_obj):
usecs_per_line=PVScan_info["usecs_per_line"],
scan_datetime=PVScan_info["scan_datetime"],
scan_duration=PVScan_info["scan_duration"],
multi_tiff=PVScan_info["multi_tiff"],
)
)

Expand Down

0 comments on commit 18d0e34

Please sign in to comment.