original_docstring: Create a coordsystem.json file and save it.
  
      Parameters
      ----------
      raw : instance of Raw
          The data as MNE-Python Raw object.
      unit : str
          Units to be used in the coordsystem specification,
          as in BIDS_COORDINATE_UNITS.
      orient : str
          Used to define the coordinate system for the head coils.
      coordsystem_name : str
          Name of the coordinate system for the sensor positions.
      fname : str
          Filename to save the coordsystem.json to.
      datatype : str
          Type of the data recording. Can be ``meg``, ``eeg``,
          or ``ieeg``.
      overwrite : bool
          Whether to overwrite the existing file.
          Defaults to False.
      verbose : bool
          Set verbose output to true or false.
  
      
docstring: Create a coordsystem.json file and save it.
  Parameters
  
  raw : instance of Raw
  The data as MNE-Python Raw object.
  unit : str
  Units to be used in the coordsystem specification,
  as in BIDS_COORDINATE_UNITS.
  orient : str
  Used to define the coordinate system for the head coils.
  coordsystem_name : str
  Name of the coordinate system for the sensor positions.
  fname : str
  Filename to save the coordsystem.json to.
  datatype : str
  Type of the data recording.
docstring_tokens: Create a coordsystem . json file and save it . Parameters raw : instance of Raw The data as MNE - Python Raw object . unit : str Units to be used in the coordsystem specification as in BIDS_COORDINATE_UNITS . orient : str Used to define the coordinate system for the head coils . coordsystem_name : str Name of the coordinate system for the sensor positions . fname : str Filename to save the coordsystem . json to . datatype : str Type of the data recording .
code: def _coordsystem_json(raw, unit, orient, coordsystem_name, fname,
                        datatype, overwrite=False, verbose=True):
      """Create a coordsystem.json file and save it.
  
      Parameters
      ----------
      raw : instance of Raw
          The data as MNE-Python Raw object.
      unit : str
          Units to be used in the coordsystem specification,
          as in BIDS_COORDINATE_UNITS.
      orient : str
          Used to define the coordinate system for the head coils.
      coordsystem_name : str
          Name of the coordinate system for the sensor positions.
      fname : str
          Filename to save the coordsystem.json to.
      datatype : str
          Type of the data recording. Can be ``meg``, ``eeg``,
          or ``ieeg``.
      overwrite : bool
          Whether to overwrite the existing file.
          Defaults to False.
      verbose : bool
          Set verbose output to true or false.
  
      """
      dig = raw.info['dig']
      if dig is None:
          dig = []
      coords = _extract_landmarks(dig)
      hpi = {d['ident']: d for d in dig if d['kind'] == FIFF.FIFFV_POINT_HPI}
      if hpi:
          for ident in hpi.keys():
              coords['coil%d' % ident] = hpi[ident]['r'].tolist()
  
      coord_frame = set([dig[ii]['coord_frame'] for ii in range(len(dig))])
      if len(coord_frame) > 1:  # noqa E501
          raise ValueError('All HPI, electrodes, and fiducials must be in the '
                           'same coordinate frame. Found: "{}"'
                           .format(coord_frame))
  
      # get the coordinate frame description
      coordsystem_desc = COORD_FRAME_DESCRIPTIONS.get(coordsystem_name, "n/a")
      if coordsystem_name == 'Other' and verbose:
          print('Using the `Other` keyword for the CoordinateSystem field. '
                'Please specify the CoordinateSystemDescription field manually.')
  
      # create the coordinate json data structure based on 'datatype'
      if datatype == 'meg':
          hpi = {d['ident']: d for d in dig if d['kind'] == FIFF.FIFFV_POINT_HPI}
          if hpi:
              for ident in hpi.keys():
                  coords['coil%d' % ident] = hpi[ident]['r'].tolist()
  
          fid_json = {
              'MEGCoordinateSystem': coordsystem_name,
              'MEGCoordinateUnits': unit,  # XXX validate this
              'MEGCoordinateSystemDescription': coordsystem_desc,
              'HeadCoilCoordinates': coords,
              'HeadCoilCoordinateSystem': orient,
              'HeadCoilCoordinateUnits': unit  # XXX validate this
          }
      elif datatype == 'eeg':
          fid_json = {
              'EEGCoordinateSystem': coordsystem_name,
              'EEGCoordinateUnits': unit,
              'EEGCoordinateSystemDescription': coordsystem_desc,
              'AnatomicalLandmarkCoordinates': coords,
              'AnatomicalLandmarkCoordinateSystem': coordsystem_name,
              'AnatomicalLandmarkCoordinateUnits': unit,
          }
      elif datatype == "ieeg":
          fid_json = {
              'iEEGCoordinateSystem': coordsystem_name,  # (Other, Pixels, ACPC)
              'iEEGCoordinateSystemDescription': coordsystem_desc,
              'iEEGCoordinateUnits': unit,  # m (MNE), mm, cm , or pixels
          }
  
      _write_json(fname, fid_json, overwrite, verbose)
code_tokens: def _coordsystem_json ( raw , unit , orient , coordsystem_name , fname , datatype , overwrite = False , verbose = True ) : dig = raw . info [ 'dig' ] if dig is None : dig = [ ] coords = _extract_landmarks ( dig ) hpi = { d [ 'ident' ] : d for d in dig if d [ 'kind' ] == FIFF . FIFFV_POINT_HPI } if hpi : for ident in hpi . keys ( ) : coords [ 'coil%d' % ident ] = hpi [ ident ] [ 'r' ] . tolist ( ) coord_frame = set ( [ dig [ ii ] [ 'coord_frame' ] for ii in range ( len ( dig ) ) ] ) if len ( coord_frame ) > 1 : raise ValueError ( 'All HPI, electrodes, and fiducials must be in the ' 'same coordinate frame. Found: "{}"' . format ( coord_frame ) ) coordsystem_desc = COORD_FRAME_DESCRIPTIONS . get ( coordsystem_name , "n/a" ) if coordsystem_name == 'Other' and verbose : print ( 'Using the `Other` keyword for the CoordinateSystem field. ' 'Please specify the CoordinateSystemDescription field manually.' ) if datatype == 'meg' : hpi = { d [ 'ident' ] : d for d in dig if d [ 'kind' ] == FIFF . FIFFV_POINT_HPI } if hpi : for ident in hpi . keys ( ) : coords [ 'coil%d' % ident ] = hpi [ ident ] [ 'r' ] . tolist ( ) fid_json = { 'MEGCoordinateSystem' : coordsystem_name , 'MEGCoordinateUnits' : unit , 'MEGCoordinateSystemDescription' : coordsystem_desc , 'HeadCoilCoordinates' : coords , 'HeadCoilCoordinateSystem' : orient , 'HeadCoilCoordinateUnits' : unit } elif datatype == 'eeg' : fid_json = { 'EEGCoordinateSystem' : coordsystem_name , 'EEGCoordinateUnits' : unit , 'EEGCoordinateSystemDescription' : coordsystem_desc , 'AnatomicalLandmarkCoordinates' : coords , 'AnatomicalLandmarkCoordinateSystem' : coordsystem_name , 'AnatomicalLandmarkCoordinateUnits' : unit , } elif datatype == "ieeg" : fid_json = { 'iEEGCoordinateSystem' : coordsystem_name , 'iEEGCoordinateSystemDescription' : coordsystem_desc , 'iEEGCoordinateUnits' : unit , } _write_json ( fname , fid_json , overwrite , verbose )
short_docstring: Create a coordsystem.json file and save it.
short_docstring_tokens: Create a coordsystem . json file and save it .
comment: """Create a coordsystem.json file and save it.
  
      Parameters
      ----------
      raw : instance of Raw
          The data as MNE-Python Raw object.
      unit : str
          Units to be used in the coordsystem specification,
          as in BIDS_COORDINATE_UNITS.
      orient : str
          Used to define the coordinate system for the head coils.
      coordsystem_name : str
          Name of the coordinate system for the sensor positions.
      fname : str
          Filename to save the coordsystem.json to.
      datatype : str
          Type of the data recording. Can be ``meg``, ``eeg``,
          or ``ieeg``.
      overwrite : bool
          Whether to overwrite the existing file.
          Defaults to False.
      verbose : bool
          Set verbose output to true or false.
  
      """$SEP$# noqa E501$SEP$# get the coordinate frame description$SEP$# create the coordinate json data structure based on 'datatype'$SEP$# XXX validate this$SEP$# XXX validate this$SEP$# (Other, Pixels, ACPC)$SEP$# m (MNE), mm, cm , or pixels