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

Extend probe constructor #206

Merged
merged 7 commits into from
Oct 16, 2023
Merged

Extend probe constructor #206

merged 7 commits into from
Oct 16, 2023

Conversation

alejoe91
Copy link
Member

@alejoe91 alejoe91 commented Jul 31, 2023

This PR adds and unifies the serial_number/model_name/manufacturer annotations.

The Probe() constructor can now take these optional argument to automatically populate the annotations. This does not change the probeinteface format specification.

I also unified the serial number retrieval from Open Ephys and SpikeGLX, plus additional metadata.

Fixes #203

@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2023

Codecov Report

Patch coverage: 95.45% and project coverage change: +0.28% 🎉

Comparison is base (3fb8864) 88.23% compared to head (f56a9d7) 88.52%.
Report is 6 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
+ Coverage   88.23%   88.52%   +0.28%     
==========================================
  Files          10       10              
  Lines        1641     1690      +49     
==========================================
+ Hits         1448     1496      +48     
- Misses        193      194       +1     
Files Changed Coverage Δ
src/probeinterface/library.py 93.54% <60.00%> (-6.46%) ⬇️
src/probeinterface/io.py 86.95% <95.65%> (+0.40%) ⬆️
src/probeinterface/probe.py 92.78% <100.00%> (+0.46%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 72 to 78
self.annotations = dict()
self.annotate(
name=name if name is not None else "",
serial_number=serial_number if serial_number is not None else "",
model_name=model_name if model_name is not None else "",
manufacturer=manufacturer if manufacturer is not None else "",
)
Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer nothing instead of empty string when None.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, fair enough ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

@alejoe91 alejoe91 added the enhancement New feature or request label Sep 1, 2023
@alejoe91
Copy link
Member Author

alejoe91 commented Sep 1, 2023

@samuelgarcia @h-mayorquin ready to review

@@ -15,7 +15,7 @@ class Probe:

"""

def __init__(self, ndim=2, si_units="um"):
def __init__(self, ndim=2, si_units="um", name=None, serial_number=None, model_name=None, manufacturer=None):
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure to like the idea of overloading the constructor with fixed annotation even if they are important.

When creating a Probe from scratch (wich a end user normally do not do) I think I prefer this:

probe = Probe(ndim=2)
probe.annotate(name=name)
probe.annotate(serial_number=serial_number)
probe.annotate(model_name=model_name)
probe.annotate(manufacturer=manufacturer)

The discussion of which annotations are important are endless.
So lets put annotations outside the constructor.

The other solution would be to put all of then (but I do not like)

probe = Probe(ndim=2, **any_annotations)

Copy link
Member Author

Choose a reason for hiding this comment

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

or another solution would be to make set_* for these 4 key annotations, so that they are still annotations (i.e., saved to file too), but the have an easier API. Whaat do you think?

Comment on lines 113 to 127
@property
def name(self):
return self.annotations.get("name", "")

@property
def serial_number(self):
return self.annotations.get("serial_number", "")

@property
def model_name(self):
return self.annotations.get("model_name", "")

@property
def manufacturer(self):
return self.annotations.get("manufacturer", "")
Copy link
Member

Choose a reason for hiding this comment

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

OK for me.

assert "2.0 - Single Shank" in probe.annotations["name"]
assert "2.0 - Single Shank" in probe.model_name
Copy link
Member

Choose a reason for hiding this comment

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

For me name of a probe is not the model name.

A name can be something which is mainingfull for a end user : like "probeA"

Copy link
Member Author

Choose a reason for hiding this comment

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

in fact this is now "model_name". The model name is the manufacturer name of the probe. Name can be anything (like ProbeA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include serial_number and model in probeinterface.Probe specification
3 participants