Encoding for somatosensory signals

@agramfort

@alexrockhill

Hi, I am a new user to MNE python moving from a different software as Python is said to be better with Machine Learning stuffs.

I have somatosensory data (both MEG and EEG) for typically developing children. We provide pneumatic stimulation to the fingers of children to see the response to such stimulus and then localize them in the brain. So far, I have been able to complete the source localization for each stimulus event on MNE. I wish to go into Encoding and Decoding now, but I don’t have much idea how to do it ( considering, I am more from Biology background and not really into coding or creating my own algorithms).

I wanted help as to how I should approach the “encoding and decoding” topic.

I already have the evoked data, time frequency analysis data, forward and inverse solutions for my subject. How could that be used for encoding and decoding?

The example I found on MNE python website was relating to the "Spectro-temporal receptive fields’, and I really have no idea if I could apply it to somatosensory data just as in my case.

San someone help me with the resources and how to go about my approach?

That would mean a lot.

Hi @Rekha, thanks for the question and welcome to the forum! Have you seen this tutorial Decoding in time-frequency space using Common Spatial Patterns (CSP) — MNE 1.0.2 documentation? That is what I think would be a good place to start. Unfortunately, MNE-Python isn’t really at the stage where you can do an analysis without any coding in my opinion. MNE-Lab might be something to try and Brainstorm and EEGLAB are very popular as well. I hope you do give it a go with modifying the example for your data and working on the code a bit. I wanted to make sure you didn’t get the impression that it would be very doable without writing code but also I don’t think you should be intimidated by writing a bit of code when it’s mostly copy-pasting with a bit of modification. If you get errors and get stuck and can’t Google your way out, feel free to post the code on this forum as well. Using three tick marks (`) before and after nicely formats code as a tip as well for example:

import mne
1 Like

I tried playing around with The Decoding MVPA code abut came up with error that said: SVD didn’t converge

The raw file is here

The code is here:

Could you tell me what is causing the error?

From the example present in the MNE python tutorials, the decoding is being done on two different stimuli( visual vs auditory) and the accuracy of which type of stimuli is being presented is being predicted if I am not wrong?

In my case, a passive pneumatic stimulation is being applied at fingers (thumb, middle finger and pinky finger) of hands of the subject, and I need to decode the stimulus.

As the evoked response localizes at approximately the same location in the brain as seen in inverse solution for all three events, will decoding give any meaningful result in my case?

I am a self learner in neuroscience, so exactly don’t understand in depth what encoding and decoding does.

Will what I am trying to do make any sense? i.e encoding and decoding same type of pneumatic stimulus on different fingers?

Also @alexrockhill @agramfort could you please look at the jupyter notebook and my preprocessed raw file to see why I get the SVD didn’t converge message?

You can try decoding different figures but you might not be successful without invasive or fMRI data. Depending on your research question, you could group all the fingers and compare to a baseline period.

HI @alexrockhill thanks for the response. I would love to explore MNE further. @richard s video on youtube was really of help to learn basics on MNE. Now coming back to my question Could you go through the files I uploaded and possibly tell me the reason behind error of SVD didn’t converge and how i can solve it

Could you post the code and error like so please?

import mne
mne.io.read_raw('foo.fif')
Opening raw data file foo.fif...
<ipython-input-2-195fdd12533e>:1: RuntimeWarning: This filename (foo.fif) does not conform to MNE naming conventions. All raw files should end with raw.fif, raw_sss.fif, raw_tsss.fif, _meg.fif, _eeg.fif, _ieeg.fif, raw.fif.gz, raw_sss.fif.gz, raw_tsss.fif.gz, _meg.fif.gz, _eeg.fif.gz or _ieeg.fif.gz
  raw = mne.io.read_raw('foo.fif')
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-195fdd12533e> in <module>
----> 1 raw = mne.io.read_raw('foo.fif')

~/projects/mne-python/mne/io/_read_raw.py in read_raw(fname, preload, verbose, **kwargs)
     94     ext = "".join(Path(fname).suffixes)
     95     if ext in readers:
---> 96         return readers[ext](fname, preload=preload, verbose=verbose, **kwargs)
     97     else:
     98         _read_unsupported(fname)

~/projects/mne-python/mne/io/fiff/raw.py in read_raw_fif(fname, allow_maxshield, preload, on_split_missing, verbose)
    480     are updated accordingly.
    481     """
--> 482     return Raw(fname=fname, allow_maxshield=allow_maxshield,
    483                preload=preload, verbose=verbose,
    484                on_split_missing=on_split_missing)

<decorator-gen-240> in __init__(self, fname, allow_maxshield, preload, on_split_missing, verbose)

~/projects/mne-python/mne/io/fiff/raw.py in __init__(self, fname, allow_maxshield, preload, on_split_missing, verbose)
     79         while next_fname is not None:
     80             raw, next_fname, buffer_size_sec = \
---> 81                 self._read_raw_file(next_fname, allow_maxshield,
     82                                     preload, do_check_ext)
     83             do_check_ext = False

<decorator-gen-241> in _read_raw_file(self, fname, allow_maxshield, preload, do_check_ext, verbose)

~/projects/mne-python/mne/io/fiff/raw.py in _read_raw_file(self, fname, allow_maxshield, preload, do_check_ext, verbose)
    144                 check_fname(fname, 'raw', endings)
    145             # filename
--> 146             fname = _check_fname(fname, 'read', True, 'fname')
    147             ext = os.path.splitext(fname)[1].lower()
    148             whole_file = preload if '.gz' in ext else False

<decorator-gen-0> in _check_fname(fname, overwrite, must_exist, name, need_dir, verbose)

~/projects/mne-python/mne/utils/check.py in _check_fname(fname, overwrite, must_exist, name, need_dir, verbose)
    242                     f'{name} does not have read permissions: {fname}')
    243     elif must_exist:
--> 244         raise FileNotFoundError(f'{name} does not exist: {fname}')
    245 
    246     return fname

FileNotFoundError: fname does not exist: /Users/alexrockhill/Desktop/foo.fif

It’s hard to keep track of the thread when the code and the discussion are different locations.