Question about HCP selective_average fxn

Hi all,

My group and I are trying to adapt some of the functions from the HCP example notebook, but we keep getting this same error when trying to compute average responses across task conditions. Any advice on how to match up these sizes? I’m not even particularly sure which dimensions are not lining up correctly, and all we changed was which task to look at.

Thanks!


3 Likes

(ignore the typo in the comment on line 2…)

Did you change the “Load individual runs for a given task” cell to load the language task image data? It’s not obvious, but the selective averaging cell depends on that.

Yes, I should have included that in the original post

It looks like the language task is defining events where the onset + duration extends beyond the length of the image acquisition. That seems strange and worth looking into (I am not an expert on the details of the HCP tasks). In the meantime, you can avoid the error by modifying the selective_average function:


  # Select the frames from each image
  selected_data = []
  for run_data, run_frames in zip(timeseries_data, frames):
    run_frames = run_frames[run_frames < run_data.shape[1]]  # <-- new line
    selected_data.append(run_data[:, run_frames])

4 Likes

I unmarked my post as the solution because it’s more of a hack than a solution :slight_smile:

If it turns out that the mismatch is expected and normal, we will update the official notebook with that new code. In the meantime, I would encourage doing increased levels of sanity checks…

3 Likes

@zach.zeisler Thanks for posting this! My group and I were struggling with trying to get it to work for quite some time now!

@michaelwaskom Thanks a lot for the prompt reply and suggested hack! :slight_smile:

FYI this fix is now in the official data loader: Updates to HCP data loader (including visualization)

Thank you! The added visualizations are excellent, too.

Yeah, but it’s still using the hack :confused:

@michaelwaskom Thanks for sharing the hack. By the way, why are the mismatches between BOLD signal recorded and calculated frames onset+duration expected and normal? Is this specific to a language math task?