Skip to content

fs paramater specification causing problem in load_physio #10

Open

Description

@me-pic

Expected Behavior

In the generate_physio function, when load_physio is called, it uses the fs specified in the parameters of generate_physio. However, for '.phys' files, this causes problem since the fs information can be retrieved from the file directly. So having fs=None (default value) lead to a fs value of NOTHING (enum type) after loading the file...

See also discussion here.

Actual Behavior

Steps to Reproduce the Problem

1.
2.
3.

Specifications

- Python version:
- peakdet version:
- Platform:

Possible solution

Since the fs parameters should still be specified if loading any file format that is not .phys, I would propose to create another mode to separate those different format rather than grouping everything under mode="physio"

Activity

  1. me-pic commented on Oct 28, 2024

    @me-pic
    ContributorAuthor

    @smoia wdyt ?

  2. smoia commented on Oct 28, 2024

    @smoia
    Member

    I didn't have a look at the code yet, is it possible that passing arguments more carefully will solve the problem?

    Also, yes, fs should be in a 'phys' file, but they should also be in the json file in BIDS format, and I don't remember us supporting anything else than that?

    Worth adding a check in the affected function rather than duplicating code, but maybe you have another solution in mind I'm not 100% understanding.

  3. me-pic commented on Oct 28, 2024

    @me-pic
    ContributorAuthor

    Should we then constrain the possible file extension here to only .phys here ?

  4. smoia commented on Oct 28, 2024

    @smoia
    Member

    Ah I see. Then yes, please separate the .physio from the other formats, creating another I/O function for those. In those, we can make sure that fs is given while loading somehow.
    Unrelated, here's some code for input of those formats:

        if isinstance(data, str):
            if os.path.exists(data):
                ext = os.path.splitext(data)[-1]
    
                if ext == '.gz':
                    ext == os.path.splitext(os.path.splitext(data)[0])[-1]
                        
                if ext == '.tsv':
                    data = np.genfromtxt(data, delimiter='\t')
                elif ext == '.csv':
                    data = np.genfromtxt(data, delimiter=',')
                else:
                    data = np.genfromtxt(data)
            else:
                raise IOError(f'Cannot find {data}')
    

    You can also use reading functions form phys2bids on top of that!

  5. me-pic commented on Oct 29, 2024

    @me-pic
    ContributorAuthor

    Thank you for that block of code, will integrate that !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions