diff --git a/ptsa/data/events.py b/ptsa/data/events.py index 2a125d7..273e1cf 100644 --- a/ptsa/data/events.py +++ b/ptsa/data/events.py @@ -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) diff --git a/ptsa/wavelet.py b/ptsa/wavelet.py index 50592e8..c08d2c8 100644 --- a/ptsa/wavelet.py +++ b/ptsa/wavelet.py @@ -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 @@ -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) diff --git a/ptsa/wica.py b/ptsa/wica.py index 76ef3cc..f7424b8 100644 --- a/ptsa/wica.py +++ b/ptsa/wica.py @@ -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 @@ -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)