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

For memory sake, make unreadable stacks that discard test pulses #22

Closed
wants to merge 252 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
252 commits
Select commit Hold shift + click to select a range
f57babd
fix mies nwb handling if entire recording is nan
campagnola Dec 6, 2019
ca595cd
miesnwb bugfix
campagnola Dec 18, 2019
9e74b46
different strategy for handling aborted sweeps
campagnola Jan 9, 2020
555e2c6
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Jan 9, 2020
5aa7a9d
minor doc update
campagnola Jan 14, 2020
53c1f85
Better initial psp yoffset
campagnola Feb 5, 2020
bbe61c4
use mode instead of mean for measuring baseline
campagnola Feb 6, 2020
0d95197
fix psp fit yoffset bounds
campagnola Feb 11, 2020
d0fff45
fix previous commit to use baseline mode
campagnola Feb 13, 2020
8f31c78
Add fit_scale_offset for analytical minimization in simple cases
campagnola Feb 14, 2020
b176956
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Feb 14, 2020
406336e
start neuroanalysis/data directory for data models
meganbkratz Mar 4, 2020
4c9088f
fixed imports for moving experiment.py into data/dataset.py
meganbkratz Mar 28, 2019
ec33a04
add find_noisy_square_pulse function for finding pulses in noisy data…
meganbkratz Oct 21, 2019
59c26f5
import fix for moving into data directory
meganbkratz Oct 23, 2019
6c55daa
fixes for python3
meganbkratz Nov 11, 2019
056f421
Adjustments for using Dataset directly with a loader class (instead o…
meganbkratz Dec 4, 2019
51f5c0c
moved loader file to here instead of optoanalysis
meganbkratz Dec 4, 2019
c13cc3f
bugfix
meganbkratz Dec 4, 2019
784788d
moved device_config to neuroanalysis
meganbkratz Dec 4, 2019
9c2372a
added pyqtgraph debug console
meganbkratz Dec 9, 2019
4aceda3
change parent property so it doesn't need to be overwritten in subcla…
meganbkratz Dec 9, 2019
368e87e
added loading for Stimuli
meganbkratz Dec 9, 2019
fcc1f44
device name lookup
meganbkratz Dec 9, 2019
86b84b0
added DatasetLoader abstract base class
meganbkratz Dec 10, 2019
e4bfb36
fix for find_noisy_square_pulses
meganbkratz Dec 10, 2019
df2f189
documentation
meganbkratz Dec 10, 2019
25feeb0
remove baseline functions from PatchClampRecording; add nearest_test_…
meganbkratz Dec 13, 2019
310d0ab
added deprecation error to explain why recording.baseline_regions no …
meganbkratz Dec 13, 2019
d05f629
cleanup device_config system
meganbkratz Dec 16, 2019
ba0cc8a
added deprecation error messages for baseline functions in PatchClamp…
meganbkratz Dec 16, 2019
9f8fe27
incorporate Luke's fix for if entire recording is nan
meganbkratz Dec 17, 2019
828d84b
simplify update_meta function
meganbkratz Dec 30, 2019
ee1ec6f
pass DatasetLoader instance to Dataset instead of class, Dataset does…
meganbkratz Dec 30, 2019
01d795d
bugfix
meganbkratz Dec 30, 2019
32b7c40
add base analyzers to neuroanalysis (copy Analyzer from aisynphys)
meganbkratz Dec 30, 2019
81b0d74
bugfix for finding correct pulse amplitudes
meganbkratz Jan 8, 2020
e2e770b
get rid of useless while loop in top_parent
meganbkratz Jan 8, 2020
7ace327
move loaders to subdirectory - start acq4 data loader
meganbkratz Jan 15, 2020
c45f6fd
have RecordingSequences be properties of dataset and have them refere…
meganbkratz Jan 15, 2020
3fe3da4
change TSeries so it accepts n-dimensional arrays
meganbkratz Jan 15, 2020
cf96ba7
change the way Recording compiles data from tseries so that it always…
meganbkratz Jan 16, 2020
7b8cff8
add __repr__ methods to dataset classes to give more helpful info
meganbkratz Jan 16, 2020
5ee18f2
Rearrangement of Analyzer classes:
meganbkratz Jan 24, 2020
3891040
moved MPBaselineAnalyzer to aisynphys, bugfix for PatchClampStimPulse…
meganbkratz Jan 27, 2020
8c141db
stop using device_config for now, implement later if needed
meganbkratz Jan 28, 2020
5cc5527
make it so each container subclass gets a loader on initiallization
meganbkratz Jan 28, 2020
392a5a3
remove sequence loading from dataset/loader for now
meganbkratz Feb 3, 2020
a3190ef
Comment out RecordingSequence -- think about removing it from dataset
meganbkratz Feb 7, 2020
d51f066
got stimulus loading working -- requires new functions in acq4
meganbkratz Feb 7, 2020
007cbfa
better errors for not implementing test pulse finding for acq4
meganbkratz Feb 7, 2020
d4194a0
made find_noisy_stim_pulses more robust (hopefully)
meganbkratz Mar 2, 2020
1bb43a3
bugfix for PWMStimPulseAnalyzer
meganbkratz Mar 2, 2020
a61e0ff
added test for old way of MiesNwb loading
meganbkratz Mar 4, 2020
ce3b594
remove sequences from Dataset init function
meganbkratz Mar 4, 2020
773b006
fix py2 print statements
meganbkratz Mar 9, 2020
4a9736d
Merge pull request #4 from meganbkratz/master
campagnola Mar 9, 2020
04439a0
added from future import print.... so as to not break in py2
meganbkratz Mar 9, 2020
9c85e6e
added test for find_noisy_square_pulses
meganbkratz Mar 11, 2020
9a53f22
add test for dataset loading
meganbkratz Mar 11, 2020
5b36a01
change path for test file to within test_data
meganbkratz Mar 11, 2020
28a4bc9
consolidate error checking for channels
meganbkratz Mar 13, 2020
873845b
fix for negative pulses
meganbkratz Mar 13, 2020
bf6de9a
added test for stim pulse analyzer
meganbkratz Mar 13, 2020
f8758d8
minor fix
campagnola Mar 16, 2020
869a4ad
Merge pull request #3 from meganbkratz/dataset_refactor_cherrypick
campagnola Mar 16, 2020
6a43c37
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Mar 16, 2020
b67b52c
Merge branch 'master' of https://github.com/AllenInstitute/neuroanalysis
meganbkratz Mar 30, 2020
18afa9a
remove mies error skipping
campagnola Apr 17, 2020
c2cf7a2
minor fixes
campagnola Apr 17, 2020
4298c2c
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Apr 17, 2020
f41d414
Merge branch 'master' of https://github.com/AllenInstitute/neuroanalysis
meganbkratz Apr 20, 2020
6b1cb9e
fix recording start_time
meganbkratz Apr 27, 2020
9397471
Merge pull request #5 from meganbkratz/dataset_loader_fix
campagnola Apr 27, 2020
c4963f2
Make numba optional
campagnola Apr 27, 2020
93d876e
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Apr 27, 2020
3985a74
make lru_cache optional as well
campagnola Apr 27, 2020
2c7743d
fix jit fallback
campagnola May 19, 2020
b231142
fixes from recent code move from aisynphys
campagnola Aug 7, 2020
b93bb26
give optional_import fromlist and package args
campagnola Sep 10, 2020
87e859d
fix for MiesStimulus UnboundLocalError
tmchartrand Sep 11, 2020
c39e766
Merge pull request #7 from tmchartrand/master
campagnola Sep 11, 2020
89be28c
Remove dead code
campagnola Sep 12, 2020
f133f39
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Sep 12, 2020
175f64c
optional_import: allow singular value for names arg
campagnola Sep 15, 2020
139a5a8
fix optional_import
campagnola Sep 17, 2020
34edf90
Add optional_import test
campagnola Sep 17, 2020
537bc84
more optional_import fixes
campagnola Sep 17, 2020
481f993
move stimulus property from PatchClampRecording to Recording
campagnola Nov 9, 2020
11654b9
Add support for mixed frequency stimuli
campagnola Nov 9, 2020
7ca7196
fix use of maxfev to match lmfit updates
campagnola Nov 9, 2020
4aa95ae
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola Nov 9, 2020
b0da8f5
MiesStimulus save/reload as base Stimulus
campagnola Feb 4, 2021
82f058e
update for packaging
outofculture Dec 7, 2021
8ab24c7
Merge pull request #8 from outofculture/pypi
campagnola Dec 7, 2021
2381982
filter stim pulses based on presence of test pulse
scseeman Dec 21, 2021
cc8e21f
Update stim_pulse.py
campagnola Dec 22, 2021
0f6f5e6
Merge pull request #9 from scseeman/stim_pulse_numbering
campagnola Dec 22, 2021
e5b4128
Add support for h5py version 3
campagnola Feb 3, 2022
ca998c9
add PSP-shaped stimulus
campagnola Apr 12, 2023
49ffde8
longer decay time on psp stimulus
campagnola May 10, 2023
f2bd7e4
Add analytical form of Psp._compute_rise_tau (Thanks Kyle Aitken!)
campagnola May 10, 2023
c8260ea
fix for corner-case errors in _compute_rise_tau
campagnola May 10, 2023
b11cac3
Qt5 update
campagnola May 12, 2023
03d016d
Qt fix
campagnola Mar 7, 2024
b5366b7
remove unused methods
campagnola Mar 7, 2024
59613a6
Add Qt shim
campagnola Mar 7, 2024
4af741b
test pulse analysis updates
campagnola Mar 15, 2024
825f16c
nb update
campagnola Mar 15, 2024
978b1ac
aaaa, running out the door
outofculture Mar 21, 2024
2f00f91
cleanups
outofculture Apr 1, 2024
cbfa62f
expose more fit details
outofculture Apr 1, 2024
d79f73c
this gets set all the time, apparently
outofculture Apr 1, 2024
19acab0
cleanups
outofculture Apr 1, 2024
fca6a17
move around for typehintery
outofculture Apr 9, 2024
fe4d40e
only used once, not named interestingly
outofculture Apr 9, 2024
e9c5430
unused code, but maybe full of ideas?
outofculture Apr 9, 2024
9ef337c
steady state for completeness
outofculture Apr 9, 2024
d16c62f
unrelated cleanups
outofculture Apr 10, 2024
8dfdc9f
expose plotting features for external use
outofculture Apr 10, 2024
cd4773a
unrelated cleanups
outofculture Apr 12, 2024
4b0477d
these features are already provided by the superclass
outofculture Apr 12, 2024
9b6f824
put the double-exp into exp.py, do some clarity and suchlike refactors
outofculture Apr 12, 2024
8779a0f
if double-exp fails, carry on with remaining analysis as best we can
outofculture Apr 16, 2024
fc12e2a
undo fat finger
outofculture Apr 20, 2024
cf4d8a0
Merge pull request #10 from outofculture/mmmayceekewfor
campagnola Apr 25, 2024
68ebf26
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
campagnola May 7, 2024
f7546c3
Add units to MiesTSeries
campagnola May 7, 2024
5b12765
version bump for release
outofculture May 9, 2024
3703a6e
Merge pull request #11 from outofculture/bump
campagnola May 9, 2024
1c85812
unrelated changes
outofculture Jul 10, 2024
0cf9550
bugfix: spelling
outofculture Jul 10, 2024
fa97fc3
use NEURON for the model cell (still failing)
outofculture Jul 10, 2024
a67449c
create the Vector after the IClamp or they won't communicate
outofculture Jul 12, 2024
e4abf15
no, what actually matters is holding onto references
outofculture Jul 12, 2024
b50363f
cleanup; paramtrize
outofculture Jul 12, 2024
b02b959
plot legend, too
outofculture Jul 13, 2024
771db96
new way of modeling access resistance; refactor to not use globals
outofculture Jul 13, 2024
83ee2ba
explode into more tests for fine-grained look at what is failing
outofculture Jul 15, 2024
ad9ef73
conic pipette sorta working?!
outofculture Jul 15, 2024
964ce7c
2 conic sections with lots of segments
outofculture Jul 15, 2024
5a23df5
manual segmentation to get equal resistance per segment
outofculture Jul 16, 2024
2d83aa3
connect the segmented pipette to VC mode
outofculture Jul 16, 2024
d101a73
more playing with the tests
outofculture Jul 17, 2024
3294676
access resistance was being counted in input resistance
outofculture Jul 20, 2024
2ad6d5b
notes and failed attempts at additional modeling
outofculture Jul 20, 2024
7fd9be9
comment out "only" param now that most tests are passing
outofculture Jul 20, 2024
f95aab5
fix labels; increase granularity of pipette simulation
outofculture Jul 20, 2024
f824fc2
conditionally create soma, allowing bath simulation
outofculture Jul 22, 2024
a8a32ca
leaky cells have smaller resting potentials
outofculture Jul 22, 2024
83b708d
refactor: rename, break apart mock test pulse
outofculture Jul 22, 2024
6c2f089
rename model arg for clarity
outofculture Jul 23, 2024
79c4fa9
first attempt at explicit hessian curve fit
outofculture Jul 23, 2024
f311c15
BROKEN mostly hand-checked hessian
outofculture Jul 23, 2024
114f633
finished hang-checking the hessian
outofculture Jul 23, 2024
53bbcc8
trying to tease out this broken fit
outofculture Jul 25, 2024
0bac68b
slight variation on assertion
outofculture Jul 25, 2024
1ca9581
hide warnings
outofculture Jul 26, 2024
af8222c
does a single-pass fit work at all?
outofculture Jul 26, 2024
601914e
broken one-pass. refactored two-pass, trying to figure it out
outofculture Jul 27, 2024
5d5fabf
dump/load interface for test pulse
outofculture Jul 29, 2024
23ad751
shorten names to fit in smaller plots
outofculture Jul 30, 2024
9ce1ac8
handle loading test pulse stacks, too
outofculture Jul 30, 2024
3750d4e
no print
outofculture Jul 30, 2024
a7f2945
put the start_time in analysis for identification purposes
outofculture Jul 31, 2024
7a455cb
allow multiple H5 files to back a single stack
outofculture Aug 1, 2024
68ca077
cache timestamp array for faster searching
outofculture Aug 1, 2024
8b74f16
fix incorrect hessian (sign, 2nd-derivative of e^(1/x))
outofculture Aug 5, 2024
a23c7f7
unrelated changes
outofculture Aug 6, 2024
ef01054
just return the two values instead of clumping them together unnecces…
outofculture Aug 6, 2024
d040e49
Add experimental exp fitting method to test notebook
campagnola Aug 7, 2024
60903fc
Merge branch 'master' into exp-fit-simplified
campagnola Aug 7, 2024
7bdaf7a
put exact_exp_fit in place (from Luke)
outofculture Aug 7, 2024
9e2e92d
no need for tau_init
outofculture Aug 7, 2024
d2d69ad
add more exp fitting unit tests
campagnola Aug 7, 2024
2adcb92
xoffset for the exact_fit
outofculture Aug 8, 2024
d467493
test fits on exact method
campagnola Aug 8, 2024
36eeed3
Merge remote-tracking branch 'origin/exp-fit-simplified' into can-we-…
outofculture Aug 8, 2024
e5ee18c
for exact fit: add nrm to the se in err, handle xoffset.
outofculture Aug 8, 2024
e398b93
more test plotting
campagnola Aug 8, 2024
83adc8c
Merge remote-tracking branch 'outofculture/can-we-pass' into exp-fit-…
campagnola Aug 8, 2024
540dad3
reduce size of exp tests
campagnola Aug 8, 2024
1672c54
allow TSeries ± TSeries
outofculture Aug 8, 2024
2f81bd3
this parameter is not a yoffset
outofculture Aug 8, 2024
f70f5f3
current failures for detailed inspection
outofculture Aug 8, 2024
e3c6587
the transient fit is not helping pass any tests
outofculture Aug 8, 2024
ddb8293
Merge remote-tracking branch 'outofculture/can-we-pass' into exp-fit-…
campagnola Aug 9, 2024
d326416
rename test_tau
campagnola Aug 9, 2024
11eea2d
include the second fit for inspection purposes
outofculture Aug 9, 2024
7f7a3f5
rename variable to match its now source
outofculture Aug 9, 2024
2d469d5
ground the pipette in bath mode
outofculture Aug 9, 2024
1d35e93
bath is behaving well, but our tests were too sensitive around 0
outofculture Aug 9, 2024
d9a2e47
use the default solver
outofculture Aug 13, 2024
99eb431
comment; whitespace
outofculture Aug 16, 2024
63df1ac
parametrize exp_fit tests
outofculture Aug 19, 2024
666bd47
allclose still fails, but the error is pretty good
outofculture Aug 20, 2024
990d771
add more info to test-pulse analysis plots
outofculture Aug 22, 2024
3a8b411
cleanup; live test data
outofculture Aug 23, 2024
d57564b
quantify fit confidence with stddev of the error surface
outofculture Aug 23, 2024
5f08aaf
higher threshold; put even simple tau and y0 into fit
outofculture Aug 23, 2024
2e282e4
fix test plot
outofculture Aug 23, 2024
35256e9
refactor: variable
outofculture Aug 23, 2024
357f043
use a measure of linearity as our confidence score
outofculture Aug 24, 2024
7964eff
tighten our threshold; fix plot; make the tests easier
outofculture Aug 24, 2024
f4dd818
so noisy warnings
outofculture Aug 28, 2024
09716f8
IC capacitance was calculated this way in ACQ4
outofculture Aug 28, 2024
64e74d1
revert! tau for a discharging capacitor only has the one resistor
outofculture Aug 28, 2024
ed1592d
import cleanup
outofculture Aug 28, 2024
97ab0c9
brief notes on the use of tau
outofculture Aug 28, 2024
ee7a990
add a source
outofculture Aug 28, 2024
035a185
more detailed defense of our uses of tau
outofculture Aug 29, 2024
022cce5
remove unused code
outofculture Aug 30, 2024
087808c
use existing save/load (but support old data for now)
outofculture Aug 30, 2024
04643ff
no importing deleted functions
outofculture Aug 30, 2024
d1ed57c
PatchClampTestPulse.__init__ does not need a stimulus arg
outofculture Aug 30, 2024
31c200e
unused, unneeded anymore
outofculture Aug 30, 2024
f4e8ad9
rename to match other neuroanalysis classes
outofculture Aug 30, 2024
12c6e22
I read the math backwards; hundredth, not hundred
outofculture Aug 30, 2024
f8fd533
only one fitter left, it gets the name
outofculture Aug 30, 2024
f3cae8d
load data from test_data submodule
outofculture Aug 30, 2024
ada0409
load wants to be able to construct the stimulus without the entire co…
outofculture Aug 30, 2024
18e90cd
add bath recording
outofculture Aug 30, 2024
59bd8de
version the test pulse save schema
outofculture Aug 30, 2024
25d42f0
allow TSeries to concat with each other
outofculture Sep 3, 2024
17c5042
put stimulus in proper format for saving
outofculture Sep 4, 2024
5e6cba8
ignore warnings in both places exp_fit is used
outofculture Sep 11, 2024
59e9f4a
more warnings it is safe to ignore
outofculture Sep 11, 2024
9e7ff14
Refactor PatchClampTestPulse to not be a Recording
outofculture Sep 11, 2024
19435da
3.10 compat for warnings
outofculture Sep 12, 2024
45cf943
Recording.save
outofculture Sep 12, 2024
3500838
share safety checks between save and copy
outofculture Sep 12, 2024
5a19693
time vals will now be none to start with
outofculture Sep 12, 2024
cd8f9a5
Merge pull request #12 from outofculture/can-we-pass
campagnola Sep 12, 2024
8459f41
oops - wrong arg order
outofculture Sep 13, 2024
1fd6fd2
more references
outofculture Sep 20, 2024
e28b6d4
version bump
outofculture Sep 20, 2024
819e704
useful property for safe closing
outofculture Sep 25, 2024
d486f74
bump again
outofculture Sep 25, 2024
14e07db
Create action for CI
campagnola Sep 25, 2024
ba5582c
Merge branch 'master' of github.com:AllenInstitute/neuroanalysis
outofculture Sep 25, 2024
605a163
CI update
campagnola Sep 25, 2024
06a36a9
Update python-package-conda.yml
campagnola Sep 25, 2024
f3ed0f6
bad old test
outofculture Sep 25, 2024
62bd49d
Fix flake complaints
campagnola Sep 25, 2024
25acad2
Merge remote-tracking branch 'origin/ci-did-it' into testable
outofculture Sep 25, 2024
5cec1b1
Merge pull request #14 from outofculture/testable
campagnola Sep 25, 2024
d20a2ce
Merge pull request #13 from outofculture/verbump
campagnola Sep 25, 2024
d21ba7d
allow TestPulseStacks to be unreadable to save on memory
outofculture Sep 30, 2024
50f1b52
version bump
outofculture Sep 30, 2024
b1ff943
test data update
outofculture Sep 30, 2024
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
38 changes: 38 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Download test data
run: |
git submodule init test_data
git submodule update test_data
- name: Install dependencies
run: |
# conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest
pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.pyc
neuroanalysis.egg-info
build/
dist/
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016 Allen Institute for Brain Science
Copyright (c) 2016- Allen Institute for Brain Science

The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
592 changes: 592 additions & 0 deletions examples/exp_fitting.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions examples/release_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
dynamics_types = ['Dep', 'Fac', 'UR', 'SMR', 'DSR']
model.Dynamics = {k:0 for k in dynamics_types}

print "Initial parameters:", model.dict_params
print "Bounds:", model.dict_bounds
print("Initial parameters:", model.dict_params)
print("Bounds:", model.dict_bounds)


# Fit the model 5 times. Each time we enable another gating mechanism.
Expand All @@ -48,10 +48,10 @@
model.Dynamics[k] = 1
fit_params.append(model.run_fit(spike_sets))

print "----- fit complete -----"
print("----- fit complete -----")

for j,params in enumerate(fit_params):
print params
print(params)
for i,spikes in enumerate(spike_sets):
x, y = spikes
output = model.eval(x, params.values())
Expand Down
4 changes: 2 additions & 2 deletions examples/test_event_detection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.Qt import QtWidgets, QtCore
import numpy as np
from neuroanalysis.data import TSeries
from neuroanalysis.ui.event_detection import EventDetector
Expand All @@ -15,7 +15,7 @@
evd = EventDetector()
evd.params['threshold'] = 5e-10

hs = QtGui.QSplitter(QtCore.Qt.Horizontal)
hs = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
pt = pg.parametertree.ParameterTree(showHeader=False)

params = pg.parametertree.Parameter.create(name='params', type='group', children=[
Expand Down
15 changes: 8 additions & 7 deletions examples/test_psp_train_fit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pyqtgraph as pg
import numpy as np

import pyqtgraph as pg
from neuroanalysis.fitting import PspTrain
from neuroanalysis.ui.fitting import FitExplorer

Expand All @@ -15,18 +16,18 @@
args = {
'yoffset': (0, 'fixed'),
'xoffset': (2e-3, -1e-3, 5e-3),
'rise_time': (rise_time, rise_time*0.5, rise_time*2),
'decay_tau': (decay_tau, decay_tau*0.5, decay_tau*2),
'rise_time': (rise_time, rise_time * 0.5, rise_time * 2),
'decay_tau': (decay_tau, decay_tau * 0.5, decay_tau * 2),
'rise_power': (2, 'fixed'),
}
for i in range(n_psp):
args['xoffset%d'%i] = (25e-3*i, 'fixed')
args['amp%d'%i] = (250e-6, 0, 10e-3)
args['xoffset%d' % i] = (25e-3 * i, 'fixed')
args['amp%d' % i] = (250e-6, 0, 10e-3)

fit_kws = {'xtol': 1e-4, 'maxfev': 1000, 'nan_policy': 'omit'}
fit_kws = {'xtol': 1e-4, 'maxfev': 1000, 'nan_policy': 'omit'}
model = PspTrain(n_psp)

args2 = {k:(v[0] if isinstance(v, tuple) else v) for k,v in args.items()}
args2 = {k: (v[0] if isinstance(v, tuple) else v) for k, v in args.items()}
y = np.random.normal(size=len(t), scale=30e-6) + model.eval(x=t, **args2)

fit = model.fit(y, x=t, params=args, fit_kws=fit_kws, method='leastsq')
Expand Down
321 changes: 321 additions & 0 deletions examples/test_pulse_analysis.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion neuroanalysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "0.0.5"
Empty file.
19 changes: 19 additions & 0 deletions neuroanalysis/analyzers/analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


class Analyzer(object):
"""Base class for attaching analysis results to a data object.
"""
@classmethod
def get(cls, obj):
"""Get the analyzer attached to a recording, or create a new one.
"""
analyzer = getattr(obj, '_' + cls.__name__, None)
if analyzer is None:
analyzer = cls(obj)
return analyzer

def _attach(self, obj):
attr = '_' + self.__class__.__name__
if hasattr(obj, attr):
raise TypeError("Object %s already has attached %s" % (obj, self.__class__.__name__))
setattr(obj, attr, self)
61 changes: 61 additions & 0 deletions neuroanalysis/analyzers/baseline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from neuroanalysis.analyzers.analyzer import Analyzer

class BaselineAnalyzer(Analyzer):

_settle_time = None ## (float) The amount of time (in seconds) to allow the cell to settle back
## to baseline after the end of a stimulus.

def __init__(self, sync_rec):
self._attach(sync_rec)
self.sync_rec = sync_rec

self._baseline_regions = None

@property
def settle_time(self):
if self._settle_time is None:
raise Exception("""%s._settle_time must be defined.
Should be a float specifying the amount of time (in seconds)
to allow the cell to settle back to baseline after the end of a stimulus.""" % self.__class__.__name__)
return self._settle_time

@property
def baseline_regions(self):
"""A list of (start,stop) time pairs where the recordings in this
sync_rec can be expected to be in a quiescent state.

"""
raise Exception("Must be implemented in subclass.")


class BaselineDistributor(Analyzer):
"""Used to find baseline regions in a trace and distribute them on request.
"""
def __init__(self, rec):
self._attach(rec)
self.rec = rec
self.baselines = [list(r) for r in rec.baseline_regions]

def get_baseline_chunk(self, duration=20e-3):
"""Return the (start, stop) indices of a chunk of unused baseline with the
given duration.
"""
for i, baseline_rgn in enumerate(self.baselines):
rgn_start, rgn_stop = baseline_rgn
if rgn_stop - rgn_start < duration:
continue
chunk_stop = rgn_start + duration
baseline_rgn[0] = chunk_stop
return rgn_start, chunk_stop

# coundn't find any baseline data of the requested length
return None

def baseline_chunks(self, duration=20e-3):
"""Iterator yielding (start, stop) indices of baseline chunks.
"""
while True:
chunk = self.get_baseline_chunk(duration)
if chunk is None:
break
yield chunk
Loading