class_docstr: Class for event segmentation of continuous fMRI data
  
  Parameters
  ----------
  n_events: int
      Number of segments to learn
  
  step_var: Callable[[int], float] : default 4 * (0.98 ** (step - 1))
      The Gaussian variance to use during fitting, as a function of the
      number of steps. Should decrease slowly over time.
  
  n_iter: int, default: 500
      Maximum number of steps to run during fitting
  
  event_chains: ndarray with length = n_events
      Array with unique value for each separate chain of events, each linked
      in the order they appear in the array
  
  split_merge: bool, default: False
      Determines whether merge/split proposals are used during fitting with
      fit(). This can improve fitting performance when events are highly
      uneven in size, but requires additional time
  
  split_merge_proposals: int, default: 1
      Number of merges and splits to consider at each step. Computation time
      scales as O(proposals^2) so this should usually be a small value
  
  Attributes
  ----------
  p_start, p_end: length n_events+1 ndarray
      initial and final prior distributions over events
  
  P: n_events+1 by n_events+1 ndarray
      HMM transition matrix
  
  ll_ : ndarray with length = number of training datasets
      Log-likelihood for training datasets over the course of training
  
  segments_:  list of (time by event) ndarrays
      Learned (soft) segmentation for training datasets
  
  event_var_ : float
      Gaussian variance at the end of learning
  
  event_pat_ : voxel by event ndarray
      Learned mean patterns for each event
class_docstr_tok: ["Class","for","event","segmentation","of","continuous","fMRI","data","Parameters","--","--","--","--","--","n_events",":","int","Number","of","segments","to","learn","step_var",":","Callable","[","[","int","]",",","float","]",":","default","4","*","(","0.98","*","*","(","step","-","1",")",")","The","Gaussian","variance","to","use","during","fitting",",","as","a","function","of","the","number","of","steps",".","Should","decrease","slowly","over","time",".","n_iter",":","int",",","default",":","500","Maximum","number","of","steps","to","run","during","fitting","event_chains",":","ndarray","with","length","=","n_events","Array","with","unique","value","for","each","separate","chain","of","events",",","each","linked","in","the","order","they","appear","in","the","array","split_merge",":","bool",",","default",":","False","Determines","whether","merge\/split","proposals","are","used","during","fitting","with","fit","(",")",".","This","can","improve","fitting","performance","when","events","are","highly","uneven","in","size",",","but","requires","additional","time","split_merge_proposals",":","int",",","default",":","1","Number","of","merges","and","splits","to","consider","at","each","step",".","Computation","time","scales","as","O","(","proposals^2",")","so","this","should","usually","be","a","small","value","Attributes","--","--","--","--","--","p_start",",","p_end",":","length","n_events+1","ndarray","initial","and","final","prior","distributions","over","events","P",":","n_events+1","by","n_events+1","ndarray","HMM","transition","matrix","ll_",":","ndarray","with","length","=","number","of","training","datasets","Log-likelihood","for","training","datasets","over","the","course","of","training","segments_",":","list","of","(","time","by","event",")","ndarrays","Learned","(","soft",")","segmentation","for","training","datasets","event_var_",":","float","Gaussian","variance","at","the","end","of","learning","event_pat_",":","voxel","by","event","ndarray","Learned","mean","patterns","for","each","event"]
docstr: Applies learned event segmentation to new testing dataset
  
  After fitting an event segmentation using fit() or setting event
  patterns directly using set_event_patterns(), this function finds the
  same sequence of event patterns in a new testing dataset.
  
  Parameters
  ----------
  testing_data: timepoint by voxel ndarray
      fMRI data to segment based on previously-learned event patterns
  
  var: float or 1D ndarray of length equal to the number of events
      default: uses variance that maximized training log-likelihood
      Variance of the event Gaussians. If scalar, all events are
      assumed to have the same variance. If fit() has not previously
      been run, this must be specifed (cannot be None).
  
  scramble: bool : default False
      If true, the order of the learned events are shuffled before
      fitting, to give a null distribution
  
  Returns
  -------
  segments : time by event ndarray
      The resulting soft segmentation. segments[t,e] = probability
      that timepoint t is in event e
  
  test_ll : float
      Log-likelihood of model fit
docstr_tok: ["Applies","learned","event","segmentation","to","new","testing","dataset","After","fitting","an","event","segmentation","using","fit","(",")","or","setting","event","patterns","directly","using","set_event_patterns","(",")",",","this","function","finds","the","same","sequence","of","event","patterns","in","a","new","testing","dataset",".","Parameters","--","--","--","--","--","testing_data",":","timepoint","by","voxel","ndarray","fMRI","data","to","segment","based","on","previously-learned","event","patterns","var",":","float","or","1D","ndarray","of","length","equal","to","the","number","of","events","default",":","uses","variance","that","maximized","training","log-likelihood","Variance","of","the","event","Gaussians",".","If","scalar",",","all","events","are","assumed","to","have","the","same","variance",".","If","fit","(",")","has","not","previously","been","run",",","this","must","be","specifed","(","can","not","be","None",")",".","scramble",":","bool",":","default","False","If","true",",","the","order","of","the","learned","events","are","shuffled","before","fitting",",","to","give","a","null","distribution","Returns","--","--","--","-","segments",":","time","by","event","ndarray","The","resulting","soft","segmentation",".","segments","[","t",",","e","]","=","probability","that","timepoint","t","is","in","event","e","test_ll",":","float","Log-likelihood","of","model","fit"]
code: def find_events(self, testing_data, var=None, scramble=False):
      """Applies learned event segmentation to new testing dataset
  
      After fitting an event segmentation using fit() or setting event
      patterns directly using set_event_patterns(), this function finds the
      same sequence of event patterns in a new testing dataset.
  
      Parameters
      ----------
      testing_data: timepoint by voxel ndarray
          fMRI data to segment based on previously-learned event patterns
  
      var: float or 1D ndarray of length equal to the number of events
          default: uses variance that maximized training log-likelihood
          Variance of the event Gaussians. If scalar, all events are
          assumed to have the same variance. If fit() has not previously
          been run, this must be specifed (cannot be None).
  
      scramble: bool : default False
          If true, the order of the learned events are shuffled before
          fitting, to give a null distribution
  
      Returns
      -------
      segments : time by event ndarray
          The resulting soft segmentation. segments[t,e] = probability
          that timepoint t is in event e
  
      test_ll : float
          Log-likelihood of model fit
      """
  
      if var is None:
          if not hasattr(self, "event_var_"):
              raise NotFittedError(
                  (
                      "Event variance must be provided, if "
                      "not previously set by fit()"
                  )
              )
          else:
              var = self.event_var_
  
      if not hasattr(self, "event_pat_"):
          raise NotFittedError(
              (
                  "The event patterns must first be set "
                  "by fit() or set_event_patterns()"
              )
          )
      if scramble:
          mean_pat = self.event_pat_[
              :, np.random.permutation(self.n_events)
          ]
      else:
          mean_pat = self.event_pat_
  
      logprob = self._logprob_obs(testing_data.T, mean_pat, var)
      lg, test_ll = self._forward_backward(logprob)
      segments = np.exp(lg)
  
      return segments, test_ll
  
imports: import numpy
  from scipy import stats
  import logging
  import copy
  from sklearn.base import BaseEstimator
  from sklearn.utils.validation import check_is_fitted, check_array
  from sklearn.exceptions import NotFittedError
  import itertools
  from .None import _utils
label_desc: Use image node_id 9 for calling the EventSegment obj's underlying member method code with example usage: obj.find_events(testing_data, var, scramble) and returns: segments,  test_ll