Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sessions Attribute Functionality Discussion. #24

Closed
ljchang opened this issue Feb 10, 2018 · 8 comments
Closed

Sessions Attribute Functionality Discussion. #24

ljchang opened this issue Feb 10, 2018 · 8 comments

Comments

@ljchang
Copy link
Member

ljchang commented Feb 10, 2018

Working on sessions attribute for Fex objects. Right now users can pass in a sessions array that can be iterated over using Fex.itersessions(), exactly the same way that pd.DataFrame.iterrows() works.

Just wanted to run a few things by @jcheong0428 and @Nathaniel-Haines. If Fex.sesssions is not None, should we iterate over every unique session for all preprocessing/descriptive/feature extraction methods? For example, Fex.downsample() should probably downsample separately for each unique session (e.g., trial, subject) right? And Fex.clean() should do the same as well as Fex.extract_boft()

@ljchang
Copy link
Member Author

ljchang commented Feb 10, 2018

Also, we need to make sure things like append() work sensibly. I assume we will want to append the session variables just like features.

We also might want to create a new session id when appending. Will probably add a flag for this too. Something like Fex.append(new_session=True)

@ljchang
Copy link
Member Author

ljchang commented Feb 10, 2018

Do you think it is worth adding a ignore_sessions=False flag to all methods that we are autodetecting sessions?

@Nathaniel-Haines
Copy link
Collaborator

Nathaniel-Haines commented Feb 11, 2018

I agree that the default behavior should be to iterate over all unique session info. For the ignore_sessions=False flag, would it be better to have ignore_sessions accept a list of column headers? That way, if I want to ignore one session variable (e.g. subject) but not another (e.g. trial), I could set ignore_sessions=['subject']. This could be data added to the class to ensure it is inherited as we chain the methods.

@ljchang
Copy link
Member Author

ljchang commented Feb 11, 2018 via email

@jcheong0428
Copy link
Member

So I think two use cases should be considered here.
The first case is when processing just 1 Subject over multiple Trials.
This is easy with how sessions is currently coded as the user just needs to pass a a list of Trials corresponding to each timepoint.

However the user needs to do a little more in use case 2 which is when they first append over multiple Subjects x Trials, and try to batch processing on all of them (I think this is the case @Nathaniel-Haines is referring to). This would make it necessary to have a unique session over subject x Trial. Then the user would then need to first generate unique session values for those interactions then pass it into sessions. This shouldn't be too hard and we can provide a function for this.

I like the way @ljchang has it coded now for simplicity but we should definitely write in the doc about how to handle the second case (which would be common for trial-based experiments).

Also having all functions iterate over sessions should be clarified in docs due to different use cases. For instance baseline() or decompose() is probably better when the session=subject but not when session=trial. But once again this could be left to the users to check our doc for best practices.

@ljchang
Copy link
Member Author

ljchang commented Feb 11, 2018

I think the current design could accomodate subject x trial, just done separately. First, user would process each subject by trial. Second, user would combine subject data and session now becomes subjects. Alternatively, users could come up with a unique subject x trial key (e.g., s001_t1), and process everything. I don't think it will be a good idea to combine subjects by trial in the sessions. We should be able to parallelize processes that iterate over sessions.

@jcheong0428
Copy link
Member

Yup I agree managing unique sessions should be left to the user.

@ljchang
Copy link
Member Author

ljchang commented Feb 12, 2018

Here is example for how to use sessions for a feature extraction method.

        if ignore_sessions:
            convolved = self.__class__(pd.DataFrame({x:convolve(y, wav, mode='same') for x,y in self.iteritems()}), sampling_freq=self.sampling_freq, features=self.features)
        else:
            convolved = self.__class__(sampling_freq=self.sampling_freq)
            for k,v in self.itersessions():
                session = self.__class__(pd.DataFrame({x:convolve(y, wav, mode='same') for x,y in v.iteritems()}), sampling_freq=self.sampling_freq, features=self.features)
                convolved = convolved.append(session, session_id=k)

We could also consider using groupby, but I think this will be easier in the long run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants