Giter VIP home page Giter VIP logo

dynamicroutingtask's People

Contributors

bjhardcastle avatar github-actions[bot] avatar samgale avatar

Watchers

 avatar  avatar

dynamicroutingtask's Issues

`subjectName` from hdf5 path vs. contents

Hey Sam,

Would it be a problem to revert back to the commented-out line for extracting subjectName below?

   class DynRoutData:

    ...

    def loadBehavData(self,filePath):

        self.behavDataPath = filePath
        
        with h5py.File(self.behavDataPath,'r') as d:
        
            # self.subjectName = d['subjectName'][()]
            self.subjectName = re.search('.*_([0-9]{6})_',os.path.basename(self.behavDataPath)).group(1)

        ...

I'm trying to use the class with hdf5s on s3 as follows:

import io
import upath     # 3rd party package for opening files from cloud storage

obj = DynRoutData()
file = io.BytesIO(
    upath.UPath(
        's3://aind-ephys-data/ecephys_670248_2023-08-03_12-04-15/behavior/DynamicRouting1_670248_20230803_123154.hdf5'
        ).read_bytes()
    )
obj.loadBehavData(file)

Which works fine for opening via h5py.File(), but can't be used as a path to extract the subject id.

If it's preferable to get the subject from the filename, perhaps we could do something like this:

    def loadBehavData(self,filePath, fileBytes=None):

        self.behavDataPath = filePath
        
        with h5py.File(fileBytes or self.behavDataPath,'r') as d:
        
            # self.subjectName = d['subjectName'][()]
            self.subjectName = re.search('.*_([0-9]{6})_',os.path.basename(self.behavDataPath)).group(1)

    ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.