fabianp / hrf_estimation

HRF estimation
13 stars 6 forks source link

function get_sample_data don't work #5

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi, Thank you for your share. When I follow the examples in the ipython notebook with the newset software, I find that I can't work through it, the error occured as below: image I guess it's because I can't access the data, I try to access the url 'http://fa.bianp.net/projects/hrf_estimation/data' from my expoler and failed: image

Another question is whether the toolbox can work on block designed data, I find that the parameter 'onsets' for hrf_estimation.glm() is an array of shape (n_trials) but not shape(n_scans).

fabianp commented 9 years ago

Hi,

thanks for the report. I however can't reproduce the issue. The function downloads the data from the URL http://fa.bianp.net/projects/hrf_estimation/data/data_common/event_matrix.mtx . Could you paste that into your browser and see what you get (the error on the URL you mention is normal, directories are Forbidden by default)?

As for your second question: it is possible to use a block design, but you'll have to create your own design matrix and then use the rank_one function:

https://pythonhosted.org/hrf_estimation/reference.html#hrf_estimation.rank_one

which takes as input the design matrix and returns the estimated h and betas. The design matrix should have columns corresponding to the different basis functions, i.e. if you are using the basis formed by a canonical HRF + derivatives, the first regressor corresponds to the first condition convoluted with the canonical HRF, the second regressor corresponds to the first condition convoluted with the derivative of the canonical HRF and so on.

Hope that helps,

Fabian

ghost commented 9 years ago

Hi, Thank you very much for your helpful response, I can download the data from the URL you offered. I downloaded the file 'event_matrix.mtx' and 'voxels_0.npy' to my computer, the code below executes successfully: a = 'D:\winpython\event_matrix.mtx' event_matrix = io.mmread(a).toarray() b = 'D:\winpython\voxels_0.npy' voxels = np.load(b) em = sparse.coo_matrix(event_matrix) fir_matrix = utils.convolve_events(event_matrix, np.eye(HRF_LENGTH)) events_train = sparse.block_diag([event_matrix] * 5).toarray() conditions_train = sparse.coo_matrix(events_train).col onsets_train = sparse.coo_matrix(events_train).row

So, I can reproduce the example now, but I still don't know what causes that. Your advice for the second question is helpful, I'll have a try on a block design data.

fabianp commented 9 years ago

Shooting in the dark, but maybe you are behind a proxy and only can access the internet through the browser? (i.e. urllib2.urlopen('http://python.org/') would fail?)

ghost commented 9 years ago

Thank you for your patient, urllib.request.urlopen('http://www.python.org/') successed. I reinstalled the Anaconda in my computer, and now the examples execute successfully.