cedalion.sim package

Submodules

cedalion.sim.synthetic_hrf module

cedalion.sim.synthetic_hrf.add_hrf_to_od(od, hrfs, stim_df)

Adds Hemodynamic Response Functions (HRFs) to optical density (OD) data based on provided stimulus dataframe (stim_df).

Parameters:
  • (cdt.NDTimeSeries) (hrfs)

  • (cdt.NDTimeSeries)

  • (pd.DataFrame) (stim_df)

Returns:

cdt.NDTimeSeries: OD data with HRFs added based on the stimulus dataframe.

cedalion.sim.synthetic_hrf.add_hrf_to_vertices(hrf_basis, num_vertices, scale=None)

Adds hemodynamic response functions (HRF) for HbO and HbR to specified vertices.

This function applies temporal HRF profiles to vertices, optionally scaling the response by a provided amplitude scale. It generates separate images for HbO and HbR and then combines them.

Parameters:
  • (xarray.DataArray) (hrf_basis)

  • (int) (num_vertices)

  • (np.array (scale)

  • optional) (Array of scale factors of shape (num_vertices) to scale the amplitude of HRFs.)

Returns:

xr.DataArray: Combined image of HbO and HbR responses across all vertices for all time points.

cedalion.sim.synthetic_hrf.build_blob(head_model, landmark, scale=<Quantity(1, 'centimeter')>, m=10.0)

Generates a blob of activity at a seed landmark.

This function generates a blob of activity on the brain surface. The blob is centered at the vertex closest to the seed landmark.

Parameters:
  • (cfm.TwoSurfaceHeadModel) (headmodel)

  • (str) (landmark)

  • (Quantity) (scale)

  • (float) (m) – the distance computation. Smaller values of m will roughen and will usually increase error in the distance computation.

Returns:

xr.DataArray: Blob image with activation values for each vertex.

cedalion.sim.synthetic_hrf.build_stim_df(num_stims, stim_dur=<Quantity(10, 'second')>, trial_types=['Stim'], min_interval=<Quantity(5, 'second')>, max_interval=<Quantity(10, 'second')>, order='alternating')

Generates a DataFrame for stimulus metadata based on provided parameters.

Stimuli can be added in an ‘alternating’ or ‘random’ order, and the inter-stimulus interval (ISI) is chosen randomly between the minimum and maximum allowed intervals.

Parameters:
  • (int) (max_interval)

  • (int)

  • (list) (trial_types)

  • (int)

  • (int)

  • (str) (order)

Returns:

pd.DataFrame: DataFrame containing stimulus metadata.

cedalion.sim.synthetic_hrf.generate_hrf(time_axis, stim_dur=<Quantity(10, 'second')>, params_basis=[0.1, 3.0, 1.8, 3.0], scale=[<Quantity(10, 'micromolar')>, <Quantity(-4, 'micromolar')>])

Generates Hemodynamic Response Function (HRF) basis functions for different chromophores.

This function calculates the HRF basis functions using gamma distributions. It supports adjusting the response scale for HbO and HbR using parameters provided in params_basis and scale.

Parameters:
  • (xr.DataArray) (time_axis)

  • (float) (stim_dur)

  • float) (scale (list of) – for each chromophore. Expected to be a flat list where pairs represent [tau, sigma] for each chromophore.

  • float)

Returns:

xarray.DataArray: A DataArray object with dimensions “time” and “chromo”, containing

the HRF basis functions for each chromophore.

cedalion.sim.synthetic_hrf.get_colors(activations, vertex_colors, log_scale=False, max_scale=None)

Maps activations to colors for visualization.

Parameters:
  • (xr.DataArray) (activations)

  • (np.array) (vertex_colors)

  • (bool) (log_scale)

  • (float) (max_scale)

Returns:

np.array: New vertex color array with same shape as vertex_colors.

cedalion.sim.synthetic_hrf.hrf_to_long_channels(hrf_model, y, geo3d, ss_tresh=<Quantity(1.5, 'centimeter')>)

Adds Hemodynamic Response Function (HRF) to optical density (OD) data in channel space.

Broadcasts the HRF model to long channels based on the source-detector distances. Short channel hrfs are filled with zeros.

Parameters:
  • (xr.DataArray) (geo3d)

  • (cdt.NDTimeSeries) (od)

  • (xr.DataArray)

  • (Quantity) (ss_tresh)

Returns:

xr.DataArray: HRFs in channel space with dimensions [“channel”, “time”, “wavelength”].

cedalion.sim.synthetic_hrf.hrfs_from_image_reco(blob, hrf_model, Adot)

Maps an activation blob on the brain to HRFs in channel space.

Parameters:
  • (xr.DataArray) (Adot)

  • (xr.DataArray)

  • (xr.DataArray)

Returns:

cdt.NDTimeseries: HRFs in channel space.

cedalion.sim.synthetic_hrf.plot_blob(blob_img, brain, seed=None, title='', log_scale=False)

Plots a blob of activity on the brain.

Parameters:
  • (xr.DataArray) (blob_img)

  • (TrimeshSurface) (brain)

  • (int) (seed)

  • (str) (title)

  • (bool) (log_scale)

Return type:

None

Module contents

Tools for creating synthetic data.