docs: def nifti2db(file_path, file_type, is_copy, step_id, db_conn, sid_by_patient=False, pid_in_vid=False):
      """Extract some meta-data from NIFTI files (actually mostly from their paths) and stores it in a DB.
  
      Arguments:
      :param file_path: File path.
      :param file_type: File type.
      :param is_copy: Indicate if this file is a copy.
      :param step_id: Step ID.
      :param db_conn: Database connection.
      :param sid_by_patient: Rarely, a data set might use study IDs which are unique by patient
      (not for the whole study).
      E.g.: LREN data. In such a case, you have to enable this flag. This will use PatientID + StudyID as a session ID.
      :param pid_in_vid: Rarely, a data set might mix patient IDs and visit IDs. E.g. : LREN data. In such a case, you
      to enable this flag. This will try to split PatientID into VisitID and PatientID.
      :return:
      """
      logging.info("Processing '%s'" % file_path)
  
      df = db_conn.db_session.query(db_conn.DataFile).filter_by(path=file_path).one_or_none()
  
      dataset = db_conn.get_dataset(step_id)
      _extract_participant(db_conn, file_path, pid_in_vid, dataset)
      visit_id = _extract_visit(db_conn, file_path, pid_in_vid, sid_by_patient, dataset)
      session_id = _extract_session(db_conn, file_path, visit_id)
      sequence_id = _extract_sequence(db_conn, file_path, session_id)
      repetition_id = _extract_repetition(db_conn, file_path, sequence_id)
  
      if not df:
          df = db_conn.DataFile(
              path=file_path,
              type=file_type,
              is_copy=is_copy,
              processing_step_id=step_id,
              repetition_id=repetition_id
          )
          db_conn.db_session.merge(df)
          db_conn.db_session.commit()
      else:
          if file_type not in [None, '', df.type]:
              df.type = file_type
              db_conn.db_session.commit()
          if is_copy not in [None, df.is_copy]:
              df.is_copy = is_copy
              db_conn.db_session.commit()
          if step_id not in [None, df.processing_step_id]:
              df.processing_step_id = step_id
              db_conn.db_session.commit()
          if repetition_id not in [None, df.repetition_id]:
              df.repetition_id = repetition_id
              db_conn.db_session.commit()