Skip to content

Fix bugs found by ai#69

Open
thomasZen wants to merge 9 commits intomasterfrom
fix_bugs_found_by_ai
Open

Fix bugs found by ai#69
thomasZen wants to merge 9 commits intomasterfrom
fix_bugs_found_by_ai

Conversation

@thomasZen
Copy link
Contributor

These potential bugs were surfaced by AI, and fixed manually.

@thomasZen thomasZen self-assigned this Feb 26, 2026
Comment on lines +58 to 60
raise ValueError("Empty masks")
elif len(masks) == 1:
roi_mask = masks[0]
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.

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

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


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'.

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'


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.


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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant