code: def drop_bids_suffix(fname):
      
      if '/' in fname:
          split = fname.split('/')
          dirnames = '/'.join(split[:-1]) + '/'
          fname = split[-1]
      else:
          dirnames = ''
      tags = [tag for tag in fname.split('_') if '-' in tag]
      fname_head = '_'.join(tags)
      fileformat = '.' + '.'.join(fname.split('.')[1:])
      return dirnames + fname_head, fileformat
docs: Given a filename sub-01_run-01_preproc.nii.gz, it will return ['sub-01_run-01', '.nii.gz']
  
      Parameters
      ----------
  
      fname : str
          BIDS filename with suffice. Directories should not be included.
  
      Returns
      -------
      fname_head : str
          BIDS filename with
      fileformat : str
          The file format (text after suffix)
  
      Note
      ------
      This assumes that there are no periods in the filename