hnn-core icon indicating copy to clipboard operation
hnn-core copied to clipboard

BUG: Dipole.data attribute not created when using `read_dipole()` for certain files

Open ntolley opened this issue 3 years ago • 1 comments

Found when trying to reproduce HNN-GUI tutorials. Reproduced via:

from urllib.request import urlretrieve
from hnn_core import read_dipole
data_url = ('https://raw.githubusercontent.com/jonescompneurolab/hnn/master/data/MEG_detection_data/S1_ongoing.txt')
urlretrieve(data_url, 'S1_ongoing.txt')
exp_dpl = read_dipole('S1_ongoing.txt')
exp_dpl.plot()

or...

data_url = ('https://raw.githubusercontent.com/jonescompneurolab/hnn/master/data/MEG_detection_data/no_trial_S1_ERP_all_avg.txt')
urlretrieve(data_url, 'no_trial_S1_ERP_all_avg.txt')
exp_dpl = read_dipole('no_trial_S1_ERP_all_avg.txt')
exp_dpl.plot()

image

Indeed for some reason the attribute is not created for this object.

ntolley avatar Jul 23 '22 18:07 ntolley

I'm guessing this has to do with the fact that this dipole file only has 2 columns

rythorpe avatar Jul 25 '22 01:07 rythorpe

@jasmainak @rythorpe can I work on this?

I tried to reproduce the error using the first snippet mentioned in the discussion

from urllib.request import urlretrieve
from hnn_core import read_dipole

data_url = ('https://raw.githubusercontent.com/jonescompneurolab/hnn/master/data/MEG_detection_data/S1_ongoing.txt')
urlretrieve(data_url, 'S1_ongoing.txt')
exp_dpl = read_dipole('S1_ongoing.txt')
exp_dpl.plot()

The file that is being fetched and the data that we are sending to the Dipole class to create an object out of it is of size (600, 1000). While the second code snippet seems to run properly without any problems as it has a size of (103,1).

aritrasinha108 avatar Mar 06 '23 17:03 aritrasinha108

You're sure the data array used to instantiate the Dipole object has shape (600, 1000)? That's a huge array and somewhat surprising....

Also, @aritrasinha108 let's get your other PR completed first before starting another.

rythorpe avatar Mar 07 '23 19:03 rythorpe

You're sure the data array used to instantiate the Dipole object has shape (600, 1000)? That's a huge array and somewhat surprising....

@rythorpe I tried to print the shape dpl_data that is being read inside the read_dipole() method from the file. Screenshot from 2023-03-08 03-36-54

And then ran the first script mentioned above in the description Screenshot from 2023-03-08 03-36-08

Got this as the output. The shape is given to be (600, 1001) Screenshot from 2023-03-08 03-36-35

Also, @aritrasinha108 let's get your other PR completed first before starting another.

Yeah, sure, I'll finish up my previous PR and then only look into it.

aritrasinha108 avatar Mar 07 '23 22:03 aritrasinha108

Sure enough. I don't think I've worked with the S1_ongoing.txt data file before which turns out to be quite larger than the others. The problem is that the data getting passed to the Dipole constructor doesn't meet any of expected shape requirements. We should add appropriate checks that throw an error when the expected read-in data shape is violated and discuss reformating the S1_ongoing.txt data file.

rythorpe avatar Mar 09 '23 16:03 rythorpe

@rythorpe can the checks be added as a fix for this issue? please let me know if its something I can work on

aritrasinha108 avatar Mar 09 '23 19:03 aritrasinha108

First we'll need to decide how to handle the current S1_ongoing.txt file, since it's formatting is an outlier among the other experimental dipole .txt files and represents a rare use-case that we probably don't want to support. I'd wait on this until @jasmainak @ntolley @chenghuzi can weigh in.

rythorpe avatar Mar 09 '23 20:03 rythorpe

I would suggest starting with the other file no_trial_S1_ERP_all_avg.txt in the PR description since that is the usual format I have seen. Which tutorial has the S1_ongoing.txt file @ntolley ?

jasmainak avatar Mar 10 '23 15:03 jasmainak

close issue?

jasmainak avatar Mar 20 '23 20:03 jasmainak

Closing in favor of #617

rythorpe avatar Mar 21 '23 00:03 rythorpe