MNE FreeSurfer Results are Inaccurate, can't determine the problem

I have been trying to utilize MNE-Python for source localization. I have .HDF5 files on 64 channel shoulder data that I am using. I first turn those .HDF5 files into .xlsx files, and then I use that as my raw data to find the source localization. I am having issues, however, as none of my results have been matching what they are supposed to match i.e. my results show the source on the wrong hemisphere or in the wrong place. I couldn’t find the specific issue with my data. I am preprocessing with a high and low pass of 1Hz and 40Hz, and I am using AutoReject to reject bad epochs. Please let me know if you need any more information.


Shoulder03Average

The following is the code I use to generate the freesurfer image:

#Calls freesurfer software to create the 3D image
fs_dir = fetch_fsaverage(verbose=True)
subjects_dir = op.dirname(fs_dir)
subject = 'fsaverage'
trans = 'fsaverage'
src = op.join(fs_dir, 'bem', 'fsaverage-ico-5-src.fif')
bem = op.join(fs_dir, 'bem', 'fsaverage-5120-5120-5120-bem-sol.fif')

#Creates the inverse operator to be used in the inverse solution to find the source location
fwd = mne.make_forward_solution(raw.info, trans=trans, src=src,
                                bem=bem, eeg=True, mindist=5.0, n_jobs=1)
info = evoked.info
inverse_operator = mne.minimum_norm.make_inverse_operator(info, fwd, noise_cov,
                                                                            loose=0.2, depth=0.8)

# Compute inverse solution
method = "sLORETA"
# dSPM, sLORETA, eLORETA
snr = 3.
lambda2 = 1. / snr ** 2
stc = mne.minimum_norm.apply_inverse(evoked_flec, inverse_operator, lambda2,
                                     method=method, pick_ori=None)
fig = mne.viz.plot_source_estimates(stc,hemi="both",initial_time=11.816, background = "black")
plt.show(fig)

#graph of channel activity per method
plt.figure()
plt.plot(1e3 * stc.times, stc.data[::100, :].T)
plt.xlabel('time (ms)')
plt.ylabel('%s value' % method)
plt.show()

Additionally, my initial plotting of my data isn’t plotting correctly. It looks like it isn’t being turned into Hz correctly, but I believe I transposed it properly.
error

The code is as follows:


#File Locations
data_path = "C:\\######shouldersample.xlsx"
trigger = pd.read_excel(r'C:\######shouldervalue.xlsx')
df = pd.read_excel (r'C:\######shouldersample.xlsx')
df2 = np.transpose(df)
subjects_dir = data_path
src_fname = subjects_dir + '/fsaverage/bem/fsaverage-ico-5-src.fif'


#64 Channels used
sampling_freq = 250
channel_names = ["Fp1","FT7","C6","P2","Fpz","FC5","T8","P4","Fp2","FC3","TP7",
                 "P6","AF7","FC1","CP5","P8","AF3","FCz","CP3","PO7","AF4","FC2"
                 ,"CP1","PO3","AF8","FC4","CPz","POz","F7","FC6","CP2","PO4","F5",
                 "FT8","CP4","PO8","F3","T7","CP6","O1","F1","C5","TP8","Oz","Fz",
                 "C3","P7","O2","F2","C1","P5","F9","F4","Cz","P3","F10","F6","C2",
                 "P1","P9","F8","C4","Pz","P10"]

#Turns .xlsx files into usable arrays
times = np.linspace(0, 1, sampling_freq, endpoint=False)
data = np.array(df2)
info = mne.create_info(ch_names=channel_names, sfreq=sampling_freq, ch_types='eeg')
raw = mne.io.RawArray(data, info)

#Plots raw channel data across a given time period
raw.plot(show_scrollbars=False, show_scalebars=False, n_channels=1, remove_dc=False)
raw.plot(block=True)

Information on versions and computer:
MNE version: 0.24.1
Windows 10

Hi @kittson,
in your position I would first focus my efforts on understanding why your signal looks weird when you plot it. We have no way of knowing, because you seem to be reading an excel file that can have an arbitrary structure.

I haven’t been able to find that out yet. A previous post mentioned to convert it to volts using this
data=(df.to_numpy().transpose()*1e-3)
which I did, but it still doesn’t have a correct graph.

My raw data excel file looks like this


It is contiguous.

My trigger file that I’m using looks like this:


Which get’s the event ID at the time it happens.

All of this data is copy pasted from the HDFVIEW, the program used to read HDF5 files.

I haven’t been able to discover any problems with what I’ve been doing, does it look like any of my data that I’m using is wrong?

I don’t know the format of your data (for example the meaning of rows and columns) so I can’t tell much by looking at the numbers (although it looks as if columns represented channels). If the data is in hdf5, maybe it is better to read it from the hdf5 file to python?

Unfortunately, we couldn’t read from the hdf5 file to python. We used hdfview to get the sample data. The columns are representative of the 64 channels we used, and the rows are representative of the time. Is there anything you can see from our code or data that is immediately wrong?

It is difficult to judge based on a screenshot of a table. I would plot the signal (raw.plot()) in the first place to see if it looks ok. Make sure to set adequate scale both on the x and y axis. I would first set the time range (x axis) to somthing between 5 - 10 seconds (for example raw.plot(duration=6)) and change the channel scaling interactively. If the signal remains as jagged as in your original post then something is wrong.