saving rotated locs for multichannel data
@@ -2400,9 +2400,7 @@ class RotationWindow(QtWidgets.QMainWindow):
later loading.
"""
- channel = self.window.view.get_channel_all_seq(
- "Save rotated localizations"
- )
+ channel = self.window.view.save_channel("Save rotated localizations")
if channel is not None:
# rotation info
@@ -2419,7 +2417,6 @@ class RotationWindow(QtWidgets.QMainWindow):
size = self.view_rot.pick_size
new_info = [{
"Generated by": "Picasso Render 3D",
- # "Last driftfile": None,
"Pick": pick,
"Pick shape": self.view_rot.pick_shape,
"Pick size": size,
@@ -2428,34 +2425,59 @@ class RotationWindow(QtWidgets.QMainWindow):
"angz": self.view_rot.angz,
}]
- # save locs (all locs from main window)
- if channel is (len(self.view_rot.paths)): # all channels
+ # combine all channels
+ if channel is (len(self.view_rot.paths) + 1):
+ base, ext = os.path.splitext(self.view_rot.paths[0])
+ out_path = base + "_multi.hdf5"
+ path, ext = QtWidgets.QFileDialog.getSaveFileName(
+ self,
+ "Save picked localizations",
+ out_path,
+ filter="*.hdf5",
+ )
+ if path:
+ # combine locs from all channels
+ all_locs = stack_arrays(
+ self.window.view.all_locs,
+ asrecarray=True,
+ usemask=False,
+ autoconvert=True,
+ )
+ all_locs.sort(kind="mergesort", order="frame")
+ info = self.view_rot.infos[0] + new_info
+ io.save_locs(path, all_locs, info)
+ # save all channels one by one
+ elif channel is (len(self.view_rot.paths)): # all channels
suffix, ok = QtWidgets.QInputDialog.getText(
self,
"Input Dialog",
"Enter suffix",
QtWidgets.QLineEdit.Normal,
- f"_arotated_{angx}_{angy}_{angz}.hdf5",
+ f"_arotated_{angx}_{angy}_{angz}",
) # get the save file suffix
if ok:
for channel in tqdm(range(len(self.view_rot.paths))):
base, ext = os.path.splitext(
self.view_rot.paths[channel]
)
- out_path = base + suffix # name of the saved files
+ out_path = base + suffix + ".hdf5"
info = self.view_rot.infos[channel] + new_info
io.save_locs(
- out_path, self.window.view.locs[channel], info
+ out_path, self.window.view.all_locs[channel], info
)
- else: # one channel
+ # save one channel only
+ else:
out_path = self.view_rot.paths[channel].replace(
".hdf5", f"_rotated_{angx}_{angy}_{angz}.hdf5"
)
path, ext = QtWidgets.QFileDialog.getSaveFileName(
- self, "Save rotated localizations", out_path, filter="*hdf5"
+ self,
+ "Save rotated localizations",
+ out_path,
+ filter="*hdf5",
)
info = self.view_rot.infos[channel] + new_info
- io.save_locs(path, self.window.view.locs[channel], info)
+ io.save_locs(path, self.window.view.all_locs[channel], info)
def closeEvent(self, event):
""" Closes all children dialogs and self. """
