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

'NoneType' object has no attribute 'get' #52

Open
imontiel92 opened this issue Dec 5, 2024 · 9 comments
Open

'NoneType' object has no attribute 'get' #52

imontiel92 opened this issue Dec 5, 2024 · 9 comments

Comments

@imontiel92
Copy link

Hi Mayo,

It’s me again. This time, I’m encountering the following error message: 'NoneType' object has no attribute 'get'. So far, I’ve tried two approaches to resolve it: 1) repeating the Kilosort analysis, and 2) using the Kilosort 4 output, but unfortunately, neither worked.

Would you be able to take a look when you have a moment? Thank you so much, I really appreciate it!

Best,
attribute_error.txt

@mayofaulkner
Copy link
Contributor

Hello, it looks like it isn't reading in the spikeglx meta data properly. Could you attach your ap.meta file for this recording and for one where the extraction worked. Are you seeing this error for many recordings or just this one?

@oliche
Copy link
Member

oliche commented Dec 6, 2024

Hello,
It looks the lf.meta file is also creating an issue. Could you please attach the LFP meta data file as well ?
Also transferring this issue to ibl-neuropixel.

Pasting the full traceback here:

cat attribute_error.txt
from pathlib import Path
from atlaselectrophysiology.extract_files import extract_data

# Path to KS2 output
ks_path = Path(r'C:\Users\yvan\Documents\npx_analysis_ivan\im0060\im0060_physiology\im0060_ks2_v1')

# Path to raw ephys data
ephys_path = Path(r'C:\Users\yvan\Documents\npx_analysis_ivan\im0060\im0060_physiology\im0060_raw_ephys_data')

# Save path
out_path = Path(r'C:\Users\yvan\Documents\npx_analysis_ivan\im0060\im0060_alf')

extract_data(ks_path, ephys_path, out_path)


C:\Users\yvan\anaconda3\Lib\site-packages\one\alf\files.py:10: FutureWarning: `one.alf.files` will be removed in version 3.0. Use `one.alf.path` instead.
  warnings.warn(
Converting to ALF:  41%|████      | 55/135 [00:04<00:07, 10.22it/s] 
Extracting waveforms:   0%|          | 0/2315.8481 [00:00<?, ?it/s]
Extracting waveforms:  52%|█████▏    | 1200.0/2315.8481 [00:07<00:06, 169.68it/s]
Converting to ALF:  41%|████      | 55/135 [00:20<00:07, 10.22it/s]4, 121.16it/s]
Extracting waveforms: 100%|██████████| 2315.8481/2315.8481 [00:25<00:00, 89.79it/s] 
Converting to ALF: 155it [00:32,  4.84it/s]                         

2024-12-05 16:08:56 INFO     extract_files.py:82   Computing QC for C:\Users\yvan\Documents\npx_analysis_ivan\im0060\im0060_physiology\im0060_raw_ephys_data\IM0060_DG left_2023-09-03_g0_g0_t0.imec0.ap.bin

19950it [16:42, 19.90it/s]                       

2024-12-05 16:25:39 INFO     extract_files.py:82   Computing QC for C:\Users\yvan\Documents\npx_analysis_ivan\im0060\im0060_physiology\im0060_raw_ephys_data\IM0060_DG left_2023-09-03_g0_g0_t0.imec0.lf.bin

  0%|          | 0/45 [00:00<?, ?it/s]

2024-12-05 16:25:40 WARNING  spikeglx.py:318  Sync trace not labeled in metadata. Assuming last trace

  0%|          | 0/45 [00:00<?, ?it/s]

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 13
     10 # Save path
     11 out_path = Path(r'C:\Users\yvan\Documents\npx_analysis_ivan\im0060\im0060_alf')
---> 13 extract_data(ks_path, ephys_path, out_path)

File c:\users\yvan\iblapps\atlaselectrophysiology\extract_files.py:142, in extract_data(ks_path, ephys_path, out_path)
    140     extract_rmsmap(efile.ap, out_folder=out_path, spectra=False)
    141 if efile.get('lf') and efile.lf.exists():
--> 142     extract_rmsmap(efile.lf, out_folder=out_path)

File c:\users\yvan\iblapps\atlaselectrophysiology\extract_files.py:93, in extract_rmsmap(fbin, out_folder, spectra)
     90 alf_object_freq = f'ephysSpectralDensity{sglx.type.upper()}'
     92 # crunch numbers
---> 93 rms = rmsmap(fbin, spectra=spectra)
     94 # output ALF files, single precision with the optional label as suffix before extension
     95 if not out_folder.exists():

File c:\users\yvan\iblapps\atlaselectrophysiology\extract_files.py:47, in rmsmap(fbin, spectra)
     45 with tqdm(total=wingen.nwin) as pbar:
     46     for first, last in wingen.firstlast:
---> 47         D = sglx.read_samples(first_sample=first, last_sample=last)[0].transpose()
     48         # remove low frequency noise below 1 Hz
     49         D = fourier.hp(D, 1 / sglx.fs, [0, 1])

File ~\anaconda3\Lib\site-packages\spikeglx.py:308, in Reader.read_samples(self, first_sample, last_sample, channels)
    306 if channels is None:
    307     channels = slice(None)
--> 308 return self.read(slice(first_sample, last_sample), channels)

File ~\anaconda3\Lib\site-packages\spikeglx.py:291, in Reader.read(self, nsel, csel, sync)
    289 darray *= self.channel_conversion_sample2v[self.type][csel]
    290 if sync:
--> 291     return darray, self.read_sync(nsel)
    292 else:
    293     return darray

File ~\anaconda3\Lib\site-packages\spikeglx.py:345, in Reader.read_sync(self, _slice, threshold, floor_percentile)
    336 def read_sync(self, _slice=slice(0, 10000), threshold=1.2, floor_percentile=10):
    337     """
    338     Reads all sync trace. Convert analog to digital with selected threshold and append to array
    339     :param _slice: samples slice
   (...)
    343     :return: int8 array
    344     """
--> 345     digital = self.read_sync_digital(_slice)
    346     analog = self.read_sync_analog(_slice)
    347     if analog is not None and floor_percentile:

File ~\anaconda3\Lib\site-packages\spikeglx.py:320, in Reader.read_sync_digital(self, _slice)
    317 if not self.meta:
    318     _logger.warning("Sync trace not labeled in metadata. Assuming last trace")
    319 return split_sync(
--> 320     self._raw[_slice, _get_sync_trace_indices_from_meta(self.meta)]
    321 )

File ~\anaconda3\Lib\site-packages\spikeglx.py:599, in _get_sync_trace_indices_from_meta(md)
    595 def _get_sync_trace_indices_from_meta(md):
    596     """
    597     Returns a list containing indices of the sync traces in the original array
    598     """
--> 599     typ = _get_type_from_meta(md)
    600     ntr = int(_get_nchannels_from_meta(md))
    601     if typ == "nidq":

File ~\anaconda3\Lib\site-packages\spikeglx.py:640, in _get_type_from_meta(md)
    636 def _get_type_from_meta(md):
    637     """
    638     Get neuropixel data type (ap, lf or nidq) from metadata
    639     """
--> 640     snsApLfSy = md.get("snsApLfSy", [-1, -1, -1])
    641     if snsApLfSy[0] == 0 and snsApLfSy[1] != 0:
    642         return "lf"

AttributeError: 'NoneType' object has no attribute 'get

@oliche oliche transferred this issue from int-brain-lab/iblapps Dec 6, 2024
@imontiel92
Copy link
Author

Hello Mayo. Sorry for the late reply. Please, find attached the files:
IM0060: a recording with the issue.
IM0021: a recording without the issue.
Let me know if you need any additional details. Thank you in advance.

npx_files.zip

@oliche
Copy link
Member

oliche commented Dec 11, 2024

Hello,

Those files look fine ! Looking at the traceback above, the problem seems to lie with the LFP metadata files.
Could you please attach IM0021.lf.meta and IM0060.lf.meta ?

@imontiel92
Copy link
Author

Hello Oliver, thank you for your help. Please find attached the files. Thank you in advance.
lfp_data.zip

@mayofaulkner
Copy link
Contributor

Hi Ivan,

Can you confirm that your lf.bin file has the same name as the meta file for this recording? e.g is IM0060_DG left_2023-09-03_g0_g0_g0_t0.imec0.lf.bin

@imontiel92
Copy link
Author

Hello, Mayo. The name is actually IM0060_DG_left_2023-09-03_g0_g0_t0.imec0.lf.bin

@mayofaulkner
Copy link
Contributor

Okay, so I think this might be the issue. The spikeglx reader looks for a meta file with the same name as the .bin file.

@imontiel92
Copy link
Author

Problem’s fixed now. Sorry for the late reply, and thanks so much for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants