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
2 changes: 2 additions & 0 deletions djimaging/autorois/cellpose_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def create_mask_from_data(self, ch0_stack, ch1_stack=None, use_ch0=True, do_3D=F

if isinstance(masks, list):
if len(masks) == 0:
raise ValueError("Empty masks")
elif len(masks) == 1:
roi_mask = masks[0]
Comment on lines +58 to 60
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if len(masks) == 0:
    roi_mask = masks[0]

did not make sense as it would throw an index error.

else:
roi_mask = np.max(masks, axis=0)
Expand Down
2 changes: 1 addition & 1 deletion djimaging/autorois/corr_roi_mask_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def corr_map_rois(stack, cut_x, cut_z, n_pix_max_x=5, n_pix_max_z=5, n_pix_max=2
ignore_map[corr_map < line_threshold] = True
ignore_map[:cut_x[0], :] = True
ignore_map[nx - cut_x[1]:, :] = True
ignore_map[:, cut_z[0]] = True
ignore_map[:, :cut_z[0]] = True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this previously did set the whole axis to True.
Now it's symmetric to how cut_x is used two lines above:

ignore_map[:cut_x[0], :] = True

ignore_map[:, nz - cut_z[1]:] = True

p_threshold = grow_threshold if grow_threshold is not None else line_threshold
Expand Down
2 changes: 1 addition & 1 deletion djimaging/tables/core/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def add_experiment(self, key, header_path, pre_data_dir, raw_data_dir, only_new,
info_entry["prep"] = "wholemount"

eye = header_dict.get("eye", "unknown")
if 'eye' == '':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

'eye' == '' did not make sense as it is always False

if eye == '':
eye = 'unknown'

if (
Expand Down
2 changes: 1 addition & 1 deletion djimaging/tables/receptivefield/rf_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def fetch_and_compute(self, key):
"""Compute offset w.r.t. stimulus center in microns"""
stim_dict = (self.stimulus_tab & key).fetch1('stim_dict')

if ('pix_scale_x_um' not in stim_dict) or ('pix_scale_x_um' not in stim_dict):
if ('pix_scale_x_um' not in stim_dict) or ('pix_scale_y_um' not in stim_dict):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it previously checked twice if pix_scale_x_um is in the stim_dict.

raise ValueError("Pixel size not found in stimulus dict")

pix_scale_x_um, pix_scale_y_um = stim_dict['pix_scale_x_um'], stim_dict['pix_scale_y_um']
Expand Down
4 changes: 2 additions & 2 deletions djimaging/utils/receptive_fields/spatial_rf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def fit_rf_model(srf, kind='gaussian', polarity=None, center=None):
qi = -1.

for polarity_i in polarities:
if kind == 'gauss':
if kind == 'gauss' or kind == 'gaussian':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default argument of the function for kind is gaussian:

def fit_rf_model(srf, kind='gaussian', polarity=None, center=None):

so we should either support it or change the default to kind='gauss'.

model_i = srf_gauss_model(srf, polarity=polarity_i, center=center)
elif kind == 'dog':
model_i = srf_dog_model(srf, polarity=polarity_i, center=center)
Expand All @@ -58,7 +58,7 @@ def fit_rf_model(srf, kind='gaussian', polarity=None, center=None):
if qi_i > qi:
model, model_fit, model_params, qi = model_i, model_i_fit, model_i_params, qi_i

if kind == 'gauss':
if kind == 'gauss' or kind == 'gaussian':
return model_fit, model_params, qi
elif kind == 'dog':
model_c_fit = model[0](xx, yy)
Expand Down
2 changes: 1 addition & 1 deletion djimaging/utils/receptive_fields/temporal_rf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def compute_polarity_and_peak_idxs(trf, nstd=1., npeaks_max=None, rf_time=None,
trf = trf.copy()
std_trf = np.std(trf)

if (rf_time is not None) or (np.isfinite(max_dt_future)):
if (rf_time is not None) and (np.isfinite(max_dt_future)):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For

rf_time = None
max_dt_future = 42.0

Below line would have checked None > 42.0 which would result in the type error TypeError: '>' not supported between instances of 'NoneType' and 'float'

trf[rf_time > max_dt_future] = 0.

pos_peak_idxs, _ = find_peaks(trf, prominence=nstd * std_trf / 2., height=nstd * std_trf)
Expand Down
8 changes: 7 additions & 1 deletion djimaging/utils/scanm/traces_and_triggers_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ def compute_frame_times(n_frames: int, pix_dt: int, npix_x: int, npix_2nd: int,
"""Compute timepoints of frames and relative delay of individual pixels.
npix_2nd can be npix_y (xy-scan) or npix_z (xz-scan)
"""
if npix_x_offset_left < 0:
raise ValueError(f"npix_x_offset_left has to be positive or 0, but was {npix_x_offset_left}")
if npix_x_offset_right < 0:
raise ValueError(f"npix_x_offset_right has to be positive or 0, but was {npix_x_offset_right}")

frame_dt = pix_dt * npix_x * npix_2nd

frame_dt_offset = (np.arange(npix_x * npix_2nd) * pix_dt).reshape(npix_2nd, npix_x).T

if precision == 'line':
frame_dt_offset = np.tile(frame_dt_offset[0, :], (npix_x, 1))

frame_dt_offset = frame_dt_offset[npix_x_offset_left:-npix_x_offset_right]
npix_x_offset_right_idx = npix_x_offset_left if npix_x_offset_left > 0 else None
frame_dt_offset = frame_dt_offset[npix_x_offset_left:-npix_x_offset_right_idx]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for npix_x_offset_right_idx=0, you get something like

frame_dt_offset[...:0]

which works, but returns an empty array.

frame_dt_offset[0:None]

returns the full array, which is what we probably want for npix_x_offset_right_idx = 0.


frame_times = np.arange(n_frames) * frame_dt

Expand Down
2 changes: 1 addition & 1 deletion djimaging/utils/scanm/wparams_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def check_dims_ch_stack_wparams(ch_stack, wparams):
nzpix = wparams.get("user_dzpix", 0)

if not (ch_stack.shape[:2] in [(nxpix, nypix), (nxpix, nzpix)]):
ValueError(f'Stack shape error: {ch_stack.shape} not in [{(nxpix, nypix)}, {(nxpix, nzpix)}]')
raise ValueError(f'Stack shape error: {ch_stack.shape} not in [{(nxpix, nypix)}, {(nxpix, nzpix)}]')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the error was not raised before.