-
Notifications
You must be signed in to change notification settings - Fork 4
Debugs for reading a .pickle file with signals #15
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
base: master
Are you sure you want to change the base?
Changes from all commits
cc3ff6d
824fc50
b4fa784
c4d96f3
7c9bfd9
ea60428
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| build/ | ||
| *__pycache__* | ||
| line.select | ||
| *.egg-info/ | ||
| .idea |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| __all__ = ['recording','volume','load_frames_legacy','redToGreen','genRedToGreen'] | ||
|
|
||
| from .recording import recording | ||
| from ._legacy_c import load_frames_legacy | ||
| from .volume import volume | ||
| from .redtogreen import redToGreen, genRedToGreen |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import numpy as np | ||
| import os | ||
| import json | ||
| import pickle | ||
|
|
||
| import numpy as np | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this line was a minor style change - styling patterns such as But if you prefer the first way just let me know; I didn't make this change holistically, but if you'd like that as well the easiest way would just be to setup |
||
|
|
||
| import wormdatamodel as wormdm | ||
|
|
||
| class recording: | ||
|
|
@@ -128,10 +130,10 @@ class recording: | |
|
|
||
| # Optogenetics | ||
| optogeneticsN = 0 | ||
| optogeneticsFrameCount = np.zeros(optogeneticsN, dtype=np.int) | ||
| optogeneticsNPulses = np.zeros(optogeneticsN, dtype=np.int) | ||
| optogeneticsRepRateDivider = np.zeros(optogeneticsN, dtype=np.int) | ||
| optogeneticsNTrains = np.zeros(optogeneticsN, dtype=np.int) | ||
| optogeneticsFrameCount = np.zeros(optogeneticsN, dtype=np.int64) | ||
| optogeneticsNPulses = np.zeros(optogeneticsN, dtype=np.int64) | ||
| optogeneticsRepRateDivider = np.zeros(optogeneticsN, dtype=np.int64) | ||
| optogeneticsNTrains = np.zeros(optogeneticsN, dtype=np.int64) | ||
|
Comment on lines
-131
to
+136
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Numpy deprecated this behavior a while back (first a soft warning for several versions; then finally a hard removal that caused some of my errors) There's actually 2 parts to it as well i) |
||
| optogeneticsTimeBtwTrains = np.zeros(optogeneticsN) | ||
| optogeneticsTargetX = np.zeros(optogeneticsN) | ||
| optogeneticsTargetY = np.zeros(optogeneticsN) | ||
|
|
@@ -674,9 +676,9 @@ def load_optogenetics(self): | |
| Line.pop(0) | ||
| if Line[-1]=="": Line.pop(-1) | ||
| self.optogeneticsN = len(Line) | ||
| self.optogeneticsFrameCount = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsNPulses = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsRepRateDivider = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsFrameCount = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsNPulses = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsRepRateDivider = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsTargetX = np.zeros(self.optogeneticsN) | ||
| self.optogeneticsTargetY = np.zeros(self.optogeneticsN) | ||
| self.optogeneticsTargetZ = np.zeros(self.optogeneticsN) | ||
|
|
@@ -686,7 +688,7 @@ def load_optogenetics(self): | |
| self.optogeneticsTime = ["None"]*self.optogeneticsN | ||
|
|
||
| #These won't be populated in this case | ||
| self.optogeneticsNTrains = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsNTrains = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsTimeBtwTrains = np.zeros(self.optogeneticsN) | ||
|
|
||
| for i in np.arange(self.optogeneticsN): | ||
|
|
@@ -707,10 +709,10 @@ def load_optogenetics(self): | |
| Line.pop(0) | ||
| if Line[-1]=="": Line.pop(-1) | ||
| self.optogeneticsN = len(Line) | ||
| self.optogeneticsFrameCount = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsNPulses = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsRepRateDivider = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsNTrains = np.zeros(self.optogeneticsN, dtype=np.int) | ||
| self.optogeneticsFrameCount = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsNPulses = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsRepRateDivider = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsNTrains = np.zeros(self.optogeneticsN, dtype=np.int64) | ||
| self.optogeneticsTimeBtwTrains = np.zeros(self.optogeneticsN) | ||
| self.optogeneticsTargetX = np.zeros(self.optogeneticsN) | ||
| self.optogeneticsTargetY = np.zeros(self.optogeneticsN) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| # Authors: Milena Chakraverti-Wuerthwein and Francesco Randi | ||
|
|
||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
| import warnings | ||
| import os | ||
| import pickle | ||
|
|
@@ -12,9 +11,7 @@ | |
| from scipy.io import loadmat as sioloadmat | ||
| from copy import deepcopy as deepcopy | ||
| from datetime import datetime | ||
| import mistofrutta.struct.irrarray as irrarray | ||
| import wormdatamodel as wormdm | ||
| import savitzkygolay as sg | ||
|
Comment on lines
-15
to
-17
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved each of these into the scopes of the functions that use them so someone can import the Using each function would still error if the package is missing, but at least that only occurs when (and 'if', in my case) those functions would be called
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative to this, if you prefer to keep things as they are, might be to include git-based installations in the setup requirements for this package That could however cascade a series of PRs like this one if there's any trouble installing those packages however |
||
| from sklearn.decomposition import FastICA | ||
|
|
||
| class Signal: | ||
|
|
@@ -95,6 +92,7 @@ def __init__(self, data, info, description = None, | |
| Detect and correct instantaneous photobleaching. Use only for the | ||
| red signal. Default: False. | ||
| ''' | ||
| import mistofrutta.struct.irrarray as irrarray | ||
|
|
||
| self.data = data; | ||
| self.info = info; | ||
|
|
@@ -630,6 +628,8 @@ def median_filter(self, i=None): | |
| self.log("Median filtering on "+affected_neurons,False) | ||
|
|
||
| def get_derivative(self,data,n,poly): | ||
| import savitzkygolay as sg | ||
|
|
||
| deriv = np.zeros_like(data) | ||
| derker = sg.get_1D_filter(n,poly,1) | ||
| #derker = savgol_coeffs(n,poly,deriv=1) | ||
|
|
@@ -823,6 +823,7 @@ def appl_photobl(self, j=None, verbose=True): | |
| #def get_photobl_fit(self, X, k=None): | ||
|
|
||
| def corr_inst_photobl(self, j=None, poly_width=111, photobl_duration=3, min_distance=30): | ||
| import savitzkygolay as sg | ||
|
|
||
| if j is None: | ||
| iterate_over = np.arange(self.data.shape[1]) | ||
|
|
@@ -923,7 +924,8 @@ def trim(self,stride_name, adjust = None): | |
| trimmed.data can now be copied and reshaped into a multidimensional | ||
| numpy array. | ||
| ''' | ||
|
|
||
| import mistofrutta.struct.irrarray as irrarray | ||
|
|
||
| try: | ||
| start = self.data.firstIndex[stride_name]; | ||
| strideLength = np.diff(start); | ||
|
|
@@ -1064,6 +1066,8 @@ def rolling_window(a, window): | |
|
|
||
| @staticmethod | ||
| def get_causal_sg(n,poly): | ||
| import savitzkygolay as sg | ||
|
|
||
| order = np.arange(poly+1) | ||
| out = np.zeros(n) | ||
| for i in order: | ||
|
|
@@ -1098,7 +1102,7 @@ def remove_outliers(y,std_th=2.): | |
| y2[outl] = y2[outl-1] | ||
|
|
||
| return y2 | ||
|
|
||
| @classmethod | ||
| def get_matchless_nan_th_from_file(cls,folder): | ||
| fname = folder+cls.matchless_nan_th_fname | ||
|
|
||
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.
Of course, this PR solves the problem by completely removing the C++ stuff
If you'd rather keep it, there are some alternative approaches I can investigate (like making it optional - or splintering it to a different repo) but they will take more time