Add files via upload
This commit is contained in:
parent
093fad58b8
commit
d211fd7050
2 changed files with 67 additions and 13 deletions
|
@ -1,17 +1,12 @@
|
||||||
{
|
{
|
||||||
"basic_path": "/data_1/robert",
|
"basic_path": "/data_1/robert",
|
||||||
"recoding_data": "2021-05-05",
|
"recoding_data": "2020-12-08",
|
||||||
"mouse_identifier": "M3852M",
|
"mouse_identifier": "M3399M",
|
||||||
"raw_path": "raw",
|
"raw_path": "raw",
|
||||||
"export_path": "output",
|
"export_path": "output",
|
||||||
"ref_image_path": "ref_images",
|
"ref_image_path": "ref_images",
|
||||||
"required_order": [
|
// Ratio Sequence
|
||||||
"acceptor",
|
"classical_ratio_mode": true, // true: a/d false: 1+a-d
|
||||||
"donor",
|
|
||||||
"oxygenation",
|
|
||||||
"volume"
|
|
||||||
],
|
|
||||||
"classical_ratio_mode": false, // true: a/d false: 1+a-d
|
|
||||||
// Regression
|
// Regression
|
||||||
"target_camera_acceptor": "acceptor",
|
"target_camera_acceptor": "acceptor",
|
||||||
"regressor_cameras_acceptor": [
|
"regressor_cameras_acceptor": [
|
||||||
|
@ -25,6 +20,7 @@
|
||||||
],
|
],
|
||||||
// binning
|
// binning
|
||||||
"binning_enable": true,
|
"binning_enable": true,
|
||||||
|
"binning_at_the_end": false,
|
||||||
"binning_kernel_size": 4,
|
"binning_kernel_size": 4,
|
||||||
"binning_stride": 4,
|
"binning_stride": 4,
|
||||||
"binning_divisor_override": 1,
|
"binning_divisor_override": 1,
|
||||||
|
@ -50,5 +46,12 @@
|
||||||
"save_alignment": false,
|
"save_alignment": false,
|
||||||
"save_heartbeat": false,
|
"save_heartbeat": false,
|
||||||
"save_factors": false,
|
"save_factors": false,
|
||||||
"save_regression_coefficients": false
|
"save_regression_coefficients": false,
|
||||||
|
// Not important parameter
|
||||||
|
"required_order": [
|
||||||
|
"acceptor",
|
||||||
|
"donor",
|
||||||
|
"oxygenation",
|
||||||
|
"volume"
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -22,6 +22,8 @@ from functions.bandpass import bandpass
|
||||||
from functions.gauss_smear_individual import gauss_smear_individual
|
from functions.gauss_smear_individual import gauss_smear_individual
|
||||||
from functions.regression import regression
|
from functions.regression import regression
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
def process_trial(
|
def process_trial(
|
||||||
|
@ -212,7 +214,7 @@ def process_trial(
|
||||||
)
|
)
|
||||||
mylogger.info("-==- Done -==-")
|
mylogger.info("-==- Done -==-")
|
||||||
|
|
||||||
if config["binning_enable"]:
|
if config["binning_enable"] and (config["binning_at_the_end"] is False):
|
||||||
mylogger.info("Binning of data")
|
mylogger.info("Binning of data")
|
||||||
mylogger.info(
|
mylogger.info(
|
||||||
(
|
(
|
||||||
|
@ -462,6 +464,7 @@ def process_trial(
|
||||||
f"max {round(float(tvec_donor_volume[:,1].max()),1)} "
|
f"max {round(float(tvec_donor_volume[:,1].max()),1)} "
|
||||||
f"mean {round(float(tvec_donor_volume[:,1].mean()),1)} "
|
f"mean {round(float(tvec_donor_volume[:,1].mean()),1)} "
|
||||||
)
|
)
|
||||||
|
|
||||||
if config["save_alignment"]:
|
if config["save_alignment"]:
|
||||||
temp_path = os.path.join(
|
temp_path = os.path.join(
|
||||||
config["export_path"], experiment_name + "_tvec_donor_volume.npy"
|
config["export_path"], experiment_name + "_tvec_donor_volume.npy"
|
||||||
|
@ -667,7 +670,7 @@ def process_trial(
|
||||||
mylogger.info("Preparation for regression -- Gauss smear")
|
mylogger.info("Preparation for regression -- Gauss smear")
|
||||||
spatial_width = float(config["gauss_smear_spatial_width"])
|
spatial_width = float(config["gauss_smear_spatial_width"])
|
||||||
|
|
||||||
if config["binning_enable"]:
|
if config["binning_enable"] and (config["binning_at_the_end"] is False):
|
||||||
spatial_width /= float(config["binning_kernel_size"])
|
spatial_width /= float(config["binning_kernel_size"])
|
||||||
|
|
||||||
mylogger.info(
|
mylogger.info(
|
||||||
|
@ -825,6 +828,35 @@ def process_trial(
|
||||||
ratio_sequence = torch.nan_to_num(ratio_sequence, nan=0.0)
|
ratio_sequence = torch.nan_to_num(ratio_sequence, nan=0.0)
|
||||||
mylogger.info("-==- Done -==-")
|
mylogger.info("-==- Done -==-")
|
||||||
|
|
||||||
|
if config["binning_enable"] and config["binning_at_the_end"]:
|
||||||
|
mylogger.info("Binning of data")
|
||||||
|
mylogger.info(
|
||||||
|
(
|
||||||
|
f"kernel_size={int(config['binning_kernel_size'])},"
|
||||||
|
f"stride={int(config['binning_stride'])},"
|
||||||
|
"divisor_override=None"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ratio_sequence = binning(
|
||||||
|
ratio_sequence.unsqueeze(-1),
|
||||||
|
kernel_size=int(config["binning_kernel_size"]),
|
||||||
|
stride=int(config["binning_stride"]),
|
||||||
|
divisor_override=None,
|
||||||
|
).squeeze(-1)
|
||||||
|
|
||||||
|
mask_positve = (
|
||||||
|
binning(
|
||||||
|
mask_positve.unsqueeze(-1).unsqueeze(-1).type(dtype=dtype),
|
||||||
|
kernel_size=int(config["binning_kernel_size"]),
|
||||||
|
stride=int(config["binning_stride"]),
|
||||||
|
divisor_override=None,
|
||||||
|
)
|
||||||
|
.squeeze(-1)
|
||||||
|
.squeeze(-1)
|
||||||
|
)
|
||||||
|
mask_positve = (mask_positve > 0).type(torch.bool)
|
||||||
|
|
||||||
if config["save_as_python"]:
|
if config["save_as_python"]:
|
||||||
temp_path = os.path.join(
|
temp_path = os.path.join(
|
||||||
config["export_path"], experiment_name + "_ratio_sequence.npz"
|
config["export_path"], experiment_name + "_ratio_sequence.npz"
|
||||||
|
@ -860,7 +892,7 @@ def process_trial(
|
||||||
mylogger.info(f"ratio_sequence = h5read('{temp_path}','/ratio_sequence');")
|
mylogger.info(f"ratio_sequence = h5read('{temp_path}','/ratio_sequence');")
|
||||||
file_handle.close()
|
file_handle.close()
|
||||||
|
|
||||||
del ratio_sequence
|
# del ratio_sequence
|
||||||
del mask_positve
|
del mask_positve
|
||||||
del mask_negative
|
del mask_negative
|
||||||
|
|
||||||
|
@ -869,6 +901,25 @@ def process_trial(
|
||||||
mylogger.info("* TRIAL END ***********************************")
|
mylogger.info("* TRIAL END ***********************************")
|
||||||
mylogger.info("***********************************************")
|
mylogger.info("***********************************************")
|
||||||
mylogger.info("")
|
mylogger.info("")
|
||||||
|
|
||||||
|
file_handle = h5py.File("old.mat", "r")
|
||||||
|
old: np.ndarray = np.array(file_handle["ratioSequence"]) # type:ignore
|
||||||
|
# HDF5 loads everything backwards...
|
||||||
|
old = np.moveaxis(old, 0, -1)
|
||||||
|
old = np.moveaxis(old, 0, -2)
|
||||||
|
|
||||||
|
pos_x = 25
|
||||||
|
pos_y = 75
|
||||||
|
|
||||||
|
plt.figure(1)
|
||||||
|
new_select = ratio_sequence[pos_x, pos_y, :].cpu()
|
||||||
|
old_select = old[pos_x, pos_y, :]
|
||||||
|
plt.plot(new_select, "r", label="New")
|
||||||
|
plt.plot(old_select, "k", label="Old")
|
||||||
|
plt.title(f"Position: {pos_x}, {pos_y}")
|
||||||
|
plt.legend()
|
||||||
|
plt.show()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue