Skip to main content

To convert snirf file to bids format.

Project description

snirf2bids pysnirf2

Table of Contents

snirf2BIDS

Conveniently generate BIDS structure from .snirf files.
Developed by BU BME Senior Design Group 3 (2022): Christian Arthur, Jeonghoon Choi, Jiazhen Liu, Juncheng Zhang.
Will be maintained by Boston University Neurophotonics Center(BUNPC).
snirf2BIDS requires Python >3 and h5py >3.6.

Features

Create BIDS-compliant Structures

def snirf_to_bids(inputpath: str, outputpath: str, participants: dict = None) creates a BIDS structure from a SNIRF file.
Inputpath: The file path to the reference SNIRF file
Outputpath: The file path/directory for the created BIDS metadata files
Participants: A dictionary with participant information

      def snirf_to_bids(inputpath: str, outputpath: str, participants: dict = None):
      
        subj = Subject(inputpath)
        subj.export('Folder', outputpath)
        _compliancy_check(subj)
        fname = outputpath + '/participants.tsv'

Create BIDS-compliant Metadata Files

def export(self, outputFormat: str = 'Folder', fpath: str = None) creats BIDS-compliant metadata files based on information stored in subject class.

OutputFormat: The target destination and indirectly, the output format of the metadata file. The default value is Folder, which outputs the metadata file to a specific file directory specified by the user.The other option is Text, which outputs the files and data as a string (JSON-like format)
fpath: The file path that points to the folder where we intend to save the metadata files in.

        def export(self, outputFormat: str = 'Folder', fpath: str = None):

        if outputFormat == 'Folder':
            self.coordsystem.save_to_json(self.subinfo, fpath)
            self.optodes.save_to_tsv(self.subinfo, fpath)
            self.optodes.export_sidecar(self.subinfo, fpath)
            self.channel.save_to_tsv(self.subinfo, fpath)
            self.channel.export_sidecar(self.subinfo, fpath)
            self.sidecar.save_to_json(self.subinfo, fpath)
            self.events.save_to_tsv(self.subinfo, fpath)
            self.events.export_sidecar(self.subinfo, fpath)
            return 0
        else:
            subj = {}
            if self.subinfo['ses-'] is None:
                subj = {'name': 'sub-' + self.get_subj(), 'filenames': self.pull_fnames(), 'sessions': self.get_ses()}

            out = json.dumps(subj)
            if fpath is None:
                return out
            else: 
                open(fpath + '/snirf.json', 'w').write(out)
                return 0

Code Generation

The fields and descriptions in JSON files are generated based on the latest Brain Imaging Data Structure v1.7.1-dev and SNIRF specification.

Maintainers

@Christian Arthur :melon:
@Juncheng Zhang :tangerine:
@Jeonghoon Choi :pineapple:
@Jiazhen Liu :grapes:
Boston University Neurophotonics Center(BUNPC)

Contributors

This project exsists thanks to all people who contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snirf2bids-0.1.20.tar.gz (7.7 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page