Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation of Neuropixels calibration files #291

Merged
merged 3 commits into from
Sep 12, 2024
Merged

Add validation of Neuropixels calibration files #291

merged 3 commits into from
Sep 12, 2024

Conversation

bparks13
Copy link
Member

@bparks13 bparks13 commented Sep 5, 2024

In this PR, the calibration files for NeuropixelsV1e, NeuropixelsV2e, and NeuropixelsV2eBeta are now validated using a custom TryParse method. This applies to the ADC / gain calibration files for NeuropixelsV1e, and the gain calibration file for NeuropixelsV2e/NeuropixelsV2eBeta.

The TryParse method will validate that the file exists and can be opened, that there are the correct number of elements, and that each element is able to be parsed into the correct type. For example, the first line in each file should contain a single element, and it should be ulong for the serial number. Other elements include the channel number, gain correction value at different gain levels, or ADC values.

Fixes #228

Related to #283, existing public methods for NeuropixelsV1e have been marked as obsolete, since they took a StreamReader as an argument instead of the filepath. These methods are not removed or modified, since doing so would be a major revision.

In addition to creating the TryParse method, this PR also takes advantage of these new methods by adding the correction values back into the various dialogs so that the user can view the ADC values and gain corrections that will be applied to the data based on the current gains selected. These are added at all dialog levels, so that anytime a file is selected, the gain will be updated in a textbox. For ADC values, instead of being in a tab like they were previously, they are now opened in a new window when a button is pressed. This window is modal, so the rest of the GUI is nonfunctional until the ADC window is closed.

Fixes #232

While adding control elements, including a status bar to display the serial number, there were some small quality-of-life changes made to control sizes.

Copy link
Member

@jonnew jonnew left a comment

Choose a reason for hiding this comment

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

I added some suggestions for improving the conciseness and strictness of the code. They pertain to np 2.0 but the same suggestions can brough to 1.0 if you think they are good changes.

OpenEphys.Onix1/NeuropixelsV2GainCorrection.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV2GainCorrection.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV2GainCorrection.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Show resolved Hide resolved
OpenEphys.Onix1.Design/NeuropixelsV1eDialog.cs Outdated Show resolved Hide resolved
@bparks13 bparks13 requested a review from jonnew September 9, 2024 21:02
OpenEphys.Onix1/NeuropixelsV2Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV2Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Outdated Show resolved Hide resolved
OpenEphys.Onix1/NeuropixelsV1Helper.cs Show resolved Hide resolved
- Refactored code (moved to helper class) and made names consistent
- Added TryParse methods for NeuropixelsV2e and NeuropixelsV1e calibration files
- Refactored code to return a nullable type instead of following the conventional TryParse pattern
- Added dialog elements that displays the current gain correction value from the gain calibration file
- Added V2 gain correction class for easier passing of correction and SN
- Display the serial number after parsing calibration files
- Add a button to open a new window for the ADC values in NeuropixelsV1eDialog
- Small update to size of controls and panels
- Added status strip for Neuropixels V1e
- Make code more concise, utilizing reactive patterns
- Add try-catch when reading from file for very specific exceptions
- Rename variables to use full names instead of abbreviations
bparks13 and others added 2 commits September 12, 2024 14:15
- IsExternalInit is now placed is its own file, since it only needs to be defined once in a namespace for records to work
- Starting folder when browsing for calibration files is set to the
  previous location if it exists
- File IO and access exceptions presented as MessageBoxs with error
  styling
Copy link
Member

@jonnew jonnew left a comment

Choose a reason for hiding this comment

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

I made some minor modifications. This is ready to merge, I think.

@jonnew jonnew merged commit f48d2f2 into main Sep 12, 2024
7 checks passed
@jonnew jonnew deleted the issue-228 branch September 12, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants