• Python

    from simnibs import optimization
    opt = optimization.TDCSoptimize()
    target = opt.add_target()


    opt = opt_struct('TDCSoptimize');


  • positions: Nx3 list/array of floats (Python/MATLAB)

    • Desctiption: Positions where the field is to be optimized. The positions are in world coordinates in subject space (see here or more information about coordinates in SimNIBS). SimNIBS finds the position in the mesh closest to the input position. These can be obtained by

      • Open the tdcs_leadfield/subID_ROI.msh file in gmsh, click in Mesh -> Inspect and click in the model

      • Open the m2m_subID/T1fs_conform.nii.gz file in a NifTi reader and record the world coordinates.

  • directions: ‘normal’ or Nx3 list/array of floats (Python/MATLAB), optional

    • Description: Direction of the field to be optimized. If set to normal and the leadfield was run with map_to_surf set to True, will optimize the normal direction (see TDCSLEADFIELD).

    • Defaut: ‘normal


    This argument is required if the leadfield obtained with map_to_surf = False, which is the default in TDCSLEADFIELD

  • indexes: Nx1 list/array of ints (Python/MATLAB), optional

    • Description: As an alternative to positions, you can select the node index (if the leadfield was run with map_to_surf = True, see TDCSLEADFIELD) or the element index (if the leadfield was run with map_to_surf = False, see TDCSLEADFIELD)

    • Default: Get the points closest to the positions.

  • intensity: float, optional

    • Description: Intensity of the field (E or J, see TDCSLEADFIELD) to be reached on average on the target and along the given direction. To optimize for intensity at the target rather than focality, you can set this value to a large number (eg: 100). With negative values, the direction will be inversed.

    • Defaut: 0.2

  • max_angle: float, optinal

    • Description: Maximum angle between field and target direction.

    • Default: No maximum


    This condition is only fulfilled in the mean across the target region, and not point-wise. Does not work in multi-target optimization.

  • radius: float, optional

  • Description: All points in the radius around the specified position/index to be added to the target area, in mm. Set to 0 if you want the target to be only the specified positions or indices.

  • Default: 2

  • tissues: list/array of ints (Python/MATLAB), optional

    • Descrption: List of tissue indices where the target is defined. Leave empty if all tissues in the leadfield. This allows you to prevent that nearby tissue regions are included in the target (e.g. white matter or CSF bordering a target in GM , assuming that all three tissues were included in the leadfield).

    • Default: All tissues