Add files via upload

This commit is contained in:
David Rotermund 2024-02-27 15:37:13 +01:00 committed by GitHub
parent 7bbac5141c
commit 093fad58b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 76 additions and 57 deletions

View file

@ -4,8 +4,6 @@
"mouse_identifier": "M3852M",
"raw_path": "raw",
"export_path": "output",
"save_as_python": true,
"save_as_matlab": true,
"ref_image_path": "ref_images",
"required_order": [
"acceptor",
@ -44,5 +42,13 @@
"skip_frames_in_the_beginning": 100, // Frames
// PyTorch
"dtype": "float32",
"force_to_cpu": false
"force_to_cpu": false,
// Save
"save_as_python": true, // produces .npz files (compressed)
"save_as_matlab": false, // produces .hd5 file (compressed)
// Save extra information
"save_alignment": false,
"save_heartbeat": false,
"save_factors": false,
"save_regression_coefficients": false
}

View file

@ -306,6 +306,7 @@ def process_trial(
f"Translation: {round(float(tvec_refref[0]),1)} x {round(float(tvec_refref[1]),1)} pixel"
)
if config["save_alignment"]:
temp_path: str = os.path.join(
config["export_path"], experiment_name + "_angle_refref.npy"
)
@ -420,6 +421,7 @@ def process_trial(
f"mean {round(float(angle_donor_volume.mean()),2)} "
)
if config["save_alignment"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_angle_donor_volume.npy"
)
@ -460,7 +462,7 @@ def process_trial(
f"max {round(float(tvec_donor_volume[:,1].max()),1)} "
f"mean {round(float(tvec_donor_volume[:,1].mean()),1)} "
)
if config["save_alignment"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_tvec_donor_volume.npy"
)
@ -536,6 +538,7 @@ def process_trial(
)
mylogger.info(f"CUDA memory: {free_mem//1024} MByte")
if config["save_heartbeat"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_volume_heartbeat.npy"
)
@ -573,6 +576,7 @@ def process_trial(
)
del y
if config["save_heartbeat"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_heartbeat_coefficients.npy"
)
@ -609,6 +613,7 @@ def process_trial(
del donor_heartbeat_factor
del acceptor_heartbeat_factor
if config["save_factors"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_donor_factor.npy"
)
@ -754,6 +759,7 @@ def process_trial(
first_none_ramp_frame=int(config["skip_frames_in_the_beginning"]),
)
if config["save_regression_coefficients"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_coefficients_acceptor.npy"
)
@ -785,6 +791,7 @@ def process_trial(
first_none_ramp_frame=int(config["skip_frames_in_the_beginning"]),
)
if config["save_regression_coefficients"]:
temp_path = os.path.join(
config["export_path"], experiment_name + "_coefficients_donor.npy"
)
@ -822,7 +829,7 @@ def process_trial(
temp_path = os.path.join(
config["export_path"], experiment_name + "_ratio_sequence.npz"
)
mylogger.info(f"Save ratio_sequence to {temp_path}")
mylogger.info(f"Save ratio_sequence and mask to {temp_path}")
np.savez_compressed(
temp_path, ratio_sequence=ratio_sequence.cpu(), mask=mask_positve.cpu()
)
@ -831,13 +838,16 @@ def process_trial(
temp_path = os.path.join(
config["export_path"], experiment_name + "_ratio_sequence.hd5"
)
mylogger.info(f"Save ratio_sequence to {temp_path}")
mylogger.info(f"Save ratio_sequence and mask to {temp_path}")
file_handle = h5py.File(temp_path, "w")
mask_positve = mask_positve.movedim(0, -1)
ratio_sequence = ratio_sequence.movedim(1, -1).movedim(0, -1)
_ = file_handle.create_dataset(
"mask", data=mask_positve.cpu(), compression="gzip", compression_opts=9
"mask",
data=mask_positve.type(torch.uint8).cpu(),
compression="gzip",
compression_opts=9,
)
_ = file_handle.create_dataset(
"ratio_sequence",
@ -845,6 +855,9 @@ def process_trial(
compression="gzip",
compression_opts=9,
)
mylogger.info("Reminder: How to read with matlab:")
mylogger.info(f"mask = h5read('{temp_path}','/mask');")
mylogger.info(f"ratio_sequence = h5read('{temp_path}','/ratio_sequence');")
file_handle.close()
del ratio_sequence