Example #1
0
 def NML2_run(self, rerun=False, a=None, **run_params):
     if not len(run_params):
         run_params = self.run_defaults
     a = ca.build_namespace(a=a,**run_params) # Convert keyword args to a namespace.  
     if self.a is None or a.__dict__ != self.a.__dict__ or rerun: # Only rerun if params have changed.  
         self.a = a
         self.lems_file_path = ca.make_lems_file(self.channel,self.a) # Create a lems file.
         self.results = ca.run_lems_file(self.lems_file_path,self.a) # Writes data to disk.  
Example #2
0
 def ca_make_lems_file(self, **params):
     # Set params in the SciUnit model instance
     self.params = params
     # ChannelAnalysis only accepts camelCase parameter names
     # This converts snake_case to camelCase
     params = {snake_to_camel(key): value for key, value in params.items()}
     # Build a namespace for use by ChannelAnalysis
     self.ca_namespace = ca.build_namespace(**params)
     # Make the new LEMS file
     self.lems_file_path = ca.make_lems_file(self.channel,
                                             self.ca_namespace)
Example #3
0
 def NML2_run(self, rerun=False, a=None, **run_params):
     if not len(run_params):
         run_params = self.run_defaults
     a = ca.build_namespace(
         a=a, **run_params)  # Convert keyword args to a namespace.
     if self.a is None or a.__dict__ != self.a.__dict__ or rerun:  # Only rerun if params have changed.
         self.a = a
         self.lems_file_path = ca.make_lems_file(
             self.channel, self.a)  # Create a lems file.
         self.results = ca.run_lems_file(self.lems_file_path,
                                         self.a)  # Writes data to disk.
Example #4
0
    def run_nml2(self,nml2_file):
        """

        :return:
        """

        return NML2ChannelAnalysis.run(channel_files=[nml2_file],nogui=False)
Example #5
0
    def __init__(self, channel_file_path, channel_index=0, name=None):
        """
        channel_file_path: Path to NML file.
        channel_index: Order of channel in NML file (usually 0 since most files contain one channel).
        name: Optional model name.
        """
        self.nml_file_path = channel_file_path
        channels = ca.get_channels_from_channel_file(self.nml_file_path)
        self.channel = channels[channel_index]
        self.a = None
        self.run_defaults = ca.DEFAULTS.copy() # Temperature, clamp parameters, etc.  
        self.run_defaults.update({'nogui': True})
        self.run_defaults = ca.build_namespace()

        if name is None:
            name = os.path.split()[1].split('.')[0]
        super(ChannelModel,self).__init__(name=name)
Example #6
0
 def produce_iv_curve(self, **run_params):
     run_params['ivCurve'] = True
     self.NML2_run(**run_params)
     self.iv_data = ca.compute_iv_curve(self.channel, self.a, self.results)
     for kind in ['i_peak', 'i_steady']:
         for v,i in self.iv_data[kind].items():
             self.iv_data[kind][v] = i * 1e12 # Convert from A to pA.  
     return self.iv_data
Example #7
0
 def produce_iv_curve(self, **run_params):
     run_params['ivCurve'] = True
     self.NML2_run(**run_params)
     self.iv_data = ca.compute_iv_curve(self.channel, self.a, self.results)
     for kind in ['i_peak', 'i_steady']:
         for v, i in self.iv_data[kind].items():
             self.iv_data[kind][v] = i * 1e12  # Convert from A to pA.
     return self.iv_data
Example #8
0
    def __init__(self, channel_file_path, channel_index=0, name=None):
        """
        channel_file_path: Path to NML file.
        channel_index: Order of channel in NML file (usually 0 since most files contain one channel).
        name: Optional model name.
        """
        self.nml_file_path = channel_file_path
        channels = ca.get_channels_from_channel_file(self.nml_file_path)
        self.channel = channels[channel_index]
        self.a = None
        self.run_defaults = ca.DEFAULTS.copy(
        )  # Temperature, clamp parameters, etc.
        self.run_defaults.update({'nogui': True})
        self.run_defaults = ca.build_namespace()

        if name is None:
            name = os.path.split()[1].split('.')[0]
        super(ChannelModel, self).__init__(name=name)
Example #9
0
 def ca_compute_iv_curve(self, results):
     iv_data = ca.compute_iv_curve(self.channel, self.ca_namespace, results)
     self.iv_data = {}
     for kind in ['i_peak', 'i_steady']:
         self.iv_data[kind] = {}
         for v, i in iv_data[kind].items():
             v = float((v * pq.V).rescale(pq.mV))
             self.iv_data[kind][v] = (i * pq.A).rescale(pq.pA)
     self.iv_data['hold_v'] = (iv_data['hold_v'] * pq.V).rescale(pq.mV)
     return self.iv_data
Example #10
0
 def produce_iv_curve(self, **run_params):
     run_params['ivCurve'] = True
     self.NML2_run(**run_params)
     iv_data = ca.compute_iv_curve(self.channel, self.a, self.results)
     self.iv_data = {}
     for kind in ['i_peak', 'i_steady']:
         self.iv_data[kind] = {}
         for v, i in iv_data[kind].items():
             v = float((v * pq.V).rescale(pq.mV))
             self.iv_data[kind][v] = (i * pq.A).rescale(pq.pA)
     self.iv_data['hold_v'] = (iv_data['hold_v'] * pq.V).rescale(pq.mV)
     return self.iv_data
Example #11
0
 def produce_iv_curve(self, **run_params):
     run_params['ivCurve'] = True
     self.NML2_run(**run_params)
     iv_data = ca.compute_iv_curve(self.channel, self.a, self.results)
     self.iv_data = {}
     for kind in ['i_peak', 'i_steady']:
         self.iv_data[kind] = {}
         for v,i in iv_data[kind].items():
             v = float((v * pq.V).rescale(pq.mV))
             self.iv_data[kind][v] = (i * pq.A).rescale(pq.pA)
     self.iv_data['hold_v'] = (iv_data['hold_v'] * pq.V).rescale(pq.mV)
     return self.iv_data
Example #12
0
 def __init__(self,
              channel_file_path_or_url,
              channel_index=0,
              name=None,
              backend='jNeuroML'):
     """
     channel_file_path: Path to NML file.
     channel_index: Order of channel in NML file
                    (usually 0 since most files contain one channel).
     name: Optional model name.
     """
     if name is None:
         base, file_name = os.path.split(channel_file_path_or_url)
         name = file_name.split('.')[0]
     super(ChannelModel, self).__init__(channel_file_path_or_url,
                                        name=name,
                                        backend=backend)
     channels = ca.get_channels_from_channel_file(self.orig_lems_file_path)
     self.channel = channels[channel_index]
     self.a = None
     # Temperature, clamp parameters, etc.
     self.default_params = ca.DEFAULTS.copy()
     self.default_params.update({'nogui': True})
Example #13
0
 def plot_iv_curve(self, v, i, *plt_args, **plt_kwargs):
     ca.plot_iv_curve(self.a, v, i, *plt_args, **plt_kwargs)
Example #14
0
 def plot_iv_curve(self, v, i, **plot_args):
     ca.plot_iv_curve(self.a, v, i, **plot_args)