Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions ptsa/data/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@ def add_fields(self,**fields):
if self.dtype.fields.has_key(name):
# already exists
raise ValueError('Field "'+name+'" already exists.')

# append the array and name
if(isinstance(data,np.dtype)|
isinstance(data,type)|isinstance(data,str)):
isinstance(data,type)):
# add empty array the length of the data
arrays.append(np.empty(len(self),data))
elif isinstance(data,str):
# populate the string-like data in an array
arrays.append(np.full(len(self),data,dtype='|S{:d}'.format(len(data))))
else:
# add the data as an array
arrays.append(data)
Expand Down
8 changes: 4 additions & 4 deletions ptsa/wavelet.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def swt(data, wavelet, level=None):
odd_indices = indices[1::2]

# get the even
(cA1,cD1) = pywt.dwt(idata[indices], wavelet, 'per')
(cA1,cD1) = pywt.dwt(idata[indices], wavelet, 'periodization')
cA[even_indices] = cA1
cD[even_indices] = cD1

# then the odd
(cA1,cD1) = pywt.dwt(np.roll(idata[indices],-1), wavelet, 'per')
(cA1,cD1) = pywt.dwt(np.roll(idata[indices],-1), wavelet, 'periodization')
cA[odd_indices] = cA1
cD[odd_indices] = cD1

Expand Down Expand Up @@ -120,8 +120,8 @@ def iswt(coefficients, wavelet):

# perform the inverse dwt on the selected indices,
# making sure to use periodic boundary conditions
x1 = pywt.idwt(output[even_indices], cD[even_indices], wavelet, 'per')
x2 = pywt.idwt(output[odd_indices], cD[odd_indices], wavelet, 'per')
x1 = pywt.idwt(output[even_indices], cD[even_indices], wavelet, 'periodization')
x2 = pywt.idwt(output[odd_indices], cD[odd_indices], wavelet, 'periodization')

# perform a circular shift right
x2 = np.roll(x2, 1)
Expand Down
7 changes: 3 additions & 4 deletions ptsa/wica.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _clean_comp(comp, Kthr, L, thld=None):
return comp, thld


def remove_strong_artifacts(data, A, icaEEG, Comp, Kthr=1.25, F=256,
def remove_strong_artifacts(icaEEG, Comp, Kthr=1.25, F=256,
Cthr=None, num_mp_procs=0):
"""
% This function denoise high amplitude artifacts (e.g. ocular) and remove them from the
Expand Down Expand Up @@ -487,14 +487,13 @@ def clean(self, comp_inds=None, Kthr=2.5, num_mp_procs=0):
# remove strong artifacts
if (not self._pure_range[0] is None) or (not self._pure_range[1] is None):
# figure out the thresh for the range
Cthr = remove_strong_artifacts(self._data[:,self._pure_range[0]:self._pure_range[1]], self.ICA_weights,
self._components[:,self._pure_range[0]:self._pure_range[1]],
Cthr = remove_strong_artifacts(self._components[:,self._pure_range[0]:self._pure_range[1]],
comp_inds, Kthr,
self._samplerate,
num_mp_procs=num_mp_procs)
else:
Cthr = None
Cthr = remove_strong_artifacts(self._data,self.ICA_weights,self._components,
Cthr = remove_strong_artifacts(self._components,
comp_inds, Kthr,
self._samplerate, Cthr,
num_mp_procs=num_mp_procs)
Expand Down