-
Notifications
You must be signed in to change notification settings - Fork 86
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 mock icephys and tests #1595
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
import numpy as np | ||
|
||
from pynwb.icephys import ( | ||
IntracellularElectrode, | ||
VoltageClampSeries, | ||
VoltageClampStimulusSeries, | ||
IntracellularRecordingsTable, | ||
CurrentClampSeries, | ||
CurrentClampStimulusSeries, | ||
IZeroClampSeries, | ||
) | ||
|
||
from .utils import name_generator | ||
from .device import mock_Device | ||
|
||
|
||
def mock_IntracellularElectrode( | ||
name=None, description="description", device=None, | ||
): | ||
return IntracellularElectrode( | ||
name=name or name_generator("IntracellularElectrode"), | ||
description=description, | ||
device=device or mock_Device(), | ||
) | ||
|
||
|
||
def mock_VoltageClampStimulusSeries( | ||
name=None, | ||
data=None, | ||
rate=100_000., | ||
electrode=None, | ||
gain=0.02, | ||
timestamps=None, | ||
starting_time=None, | ||
): | ||
return VoltageClampStimulusSeries( | ||
name=name or name_generator("VoltageClampStimulusSeries"), | ||
data=data or np.ones((30,)), | ||
rate=None if timestamps else rate, | ||
electrode=electrode or mock_IntracellularElectrode(), | ||
gain=gain, | ||
timestamps=timestamps, | ||
starting_time=starting_time, | ||
) | ||
|
||
|
||
def mock_VoltageClampSeries( | ||
name=None, | ||
data=None, | ||
conversion=1.0, | ||
resolution=np.nan, | ||
starting_time=None, | ||
rate=100_000.0, | ||
electrode=None, | ||
gain=0.02, | ||
capacitance_slow=100e-12, | ||
resistance_comp_correction=70.0, | ||
): | ||
return VoltageClampSeries( | ||
name=name if name is not None else name_generator("VoltageClampSeries"), | ||
data=data if data is not None else np.ones((30,)), | ||
conversion=conversion, | ||
resolution=resolution, | ||
starting_time=starting_time, | ||
rate=rate, | ||
electrode=electrode or mock_IntracellularElectrode(), | ||
gain=gain, | ||
capacitance_slow=capacitance_slow, | ||
resistance_comp_correction=resistance_comp_correction, | ||
) | ||
|
||
|
||
def mock_CurrentClampSeries( | ||
name=None, | ||
data=None, | ||
electrode=None, | ||
gain=0.02, | ||
stimulus_description="N/A", | ||
bias_current=None, | ||
bridge_balance=None, | ||
capacitance_compensation=None, | ||
resolution=-1.0, | ||
conversion=1.0, | ||
timestamps=None, | ||
starting_time=None, | ||
rate=100_000., | ||
comments="no comments", | ||
description="no description", | ||
control=None, | ||
control_description=None, | ||
sweep_number=None, | ||
offset=0.0, | ||
unit="volts", | ||
): | ||
return CurrentClampSeries( | ||
name=name if name is not None else name_generator("CurrentClampSeries"), | ||
data=data if data is not None else np.ones((30,)), | ||
electrode=electrode or mock_IntracellularElectrode(), | ||
gain=gain, | ||
stimulus_description=stimulus_description, | ||
bias_current=bias_current, | ||
bridge_balance=bridge_balance, | ||
capacitance_compensation=capacitance_compensation, | ||
resolution=resolution, | ||
conversion=conversion, | ||
timestamps=timestamps, | ||
starting_time=starting_time, | ||
rate=rate, | ||
comments=comments, | ||
description=description, | ||
control=control, | ||
control_description=control_description, | ||
sweep_number=sweep_number, | ||
offset=offset, | ||
unit=unit, | ||
) | ||
|
||
|
||
def mock_CurrentClampStimulusSeries( | ||
name=None, | ||
data=None, | ||
electrode=None, | ||
gain=0.02, | ||
stimulus_description="N/A", | ||
resolution=-1.0, | ||
conversion=1.0, | ||
timestamps=None, | ||
starting_time=None, | ||
rate=100_000., | ||
comments="no comments", | ||
description="no description", | ||
control=None, | ||
control_description=None, | ||
sweep_number=None, | ||
offset=0.0, | ||
unit="amperes", | ||
): | ||
return CurrentClampStimulusSeries( | ||
name=name or name_generator("CurrentClampStimulusSeries"), | ||
data=data if data is not None else np.ones((30,)), | ||
electrode=electrode or mock_IntracellularElectrode(), | ||
gain=gain, | ||
stimulus_description=stimulus_description, | ||
resolution=resolution, | ||
conversion=conversion, | ||
timestamps=timestamps, | ||
starting_time=starting_time, | ||
rate=rate, | ||
comments=comments, | ||
description=description, | ||
control=control, | ||
control_description=control_description, | ||
sweep_number=sweep_number, | ||
offset=offset, | ||
unit=unit, | ||
) | ||
|
||
|
||
def mock_IZeroClampSeries( | ||
name=None, | ||
data=None, | ||
electrode=None, | ||
gain=.02, | ||
stimulus_description="N/A", | ||
resolution=-1.0, | ||
conversion=1.0, | ||
timestamps=None, | ||
starting_time=None, | ||
rate=100_000., | ||
comments="no comments", | ||
description="no description", | ||
control=None, | ||
control_description=None, | ||
sweep_number=None, | ||
offset=0.0, | ||
unit="volts", | ||
): | ||
return IZeroClampSeries( | ||
name=name or name_generator("IZeroClampSeries"), | ||
data=data if data is not None else np.ones((30,)), | ||
electrode=electrode or mock_IntracellularElectrode(), | ||
gain=gain, | ||
stimulus_description=stimulus_description, | ||
resolution=resolution, | ||
conversion=conversion, | ||
timestamps=timestamps, | ||
starting_time=starting_time, | ||
rate=rate, | ||
comments=comments, | ||
description=description, | ||
control=control, | ||
control_description=control_description, | ||
sweep_number=sweep_number, | ||
offset=offset, | ||
unit=unit, | ||
) | ||
|
||
|
||
def mock_IntracellularRecordingsTable(n_rows=5): | ||
irt = IntracellularRecordingsTable() | ||
for _ in range(n_rows): | ||
electrode = mock_IntracellularElectrode() | ||
irt.add_recording( | ||
electrode=electrode, | ||
stimulus=mock_VoltageClampStimulusSeries(electrode=electrode), | ||
response=mock_VoltageClampSeries(electrode=electrode), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know this was a thing in Python!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty cool, huh?