Explorar o código

localCTV: added sample file to VIEWtemplates

Giovanni Galizia %!s(int64=2) %!d(string=hai) anos
pai
achega
422cb63d73

+ 74 - 0
VIEWtemplates/localCTV.py

@@ -0,0 +1,74 @@
+
+import numpy as np
+
+
+
+
+# #expected signature is like this:
+# def ctv_dummy(
+#         time_trace, sampling_period,
+#         first_frame, last_frame,
+#         stimulus_number, stim_on_times, stim_off_times,
+#         flags, p1):
+#     """
+#     dummy CTV to specify function call signature
+#     :param time_trace: iterable of numbers
+#     :param sampling_period: float, sampling period of <time_trace>, in ms
+#     :param first_frame: int, interpreted as a frame number, where frames are numbered 0, 1, 2...
+#     :param last_frame: int, interpreted as a frame number, where frames are numbered 0, 1, 2...
+#     :param stimulus_number: int, indicates the which stimulus to use, use 1 for first stimulus
+#     :param stim_on_times: list of floats, stimulus onset times, in ms
+#     :param stim_off_times: list of floats, stimulus offset times, in ms
+#     :param flags: FlagsManager object, is a mapping of flag names to flags values with additional functions
+#     :param p1: pandas.Series object, internal representation of data
+#     :rtype: list
+#     :return: one member, float
+#     """
+#     return [0]
+
+def ctvBente(time_trace, sampling_period,
+        first_frame, last_frame,
+        stimulus_number, stim_on_times, stim_off_times,
+        flags, p1):
+    """
+    ana's method -222
+    mean(13-16) - mean(6-9) 4 frames each
+    <insert a brief description of the method here>
+    :param time_trace: iterable of numbers
+    :param first_frame: int, interpreted as a frame number, where frames are numbered 1, 2, 3...
+    :param last_frame: int, interpreted as a frame number, where frames are numbered 1, 2, 3...
+    :param sampling_period: float, sampling period of <time_trace>, in ms
+    :param stim_on_times: list of floats, stimulus onset times, in ms
+    :param stim_off_times: list of floats, stimulus offset times, in ms
+    :param flags: FlagsManager object, is a mapping of flag names to flags values with additional functions
+    :param p1: pandas.Series object, internal representation of data
+    :return: float
+    """
+    # print('**************************** running ctvBente now: ')
+    # print('len time trace is: ', str(len(time_trace)))
+    
+    
+    output = np.mean(time_trace[30:40]) - np.mean(time_trace[10:20])
+    return [output]
+
+
+def myownctv22(time_trace, sampling_period,
+        first_frame, last_frame,
+        stimulus_number, stim_on_times, stim_off_times,
+        flags, p1):
+    """
+    ana's method -222
+    mean(13-16) - mean(6-9) 4 frames each
+    <insert a brief description of the method here>
+    :param time_trace: iterable of numbers
+    :param first_frame: int, interpreted as a frame number, where frames are numbered 1, 2, 3...
+    :param last_frame: int, interpreted as a frame number, where frames are numbered 1, 2, 3...
+    :param sampling_period: float, sampling period of <time_trace>, in ms
+    :param stim_on_times: list of floats, stimulus onset times, in ms
+    :param stim_off_times: list of floats, stimulus offset times, in ms
+    :param flags: FlagsManager object, is a mapping of flag names to flags values with additional functions
+    :param p1: pandas.Series object, internal representation of data
+    :return: float
+    """
+    output = np.mean(time_trace[30:40]) - np.mean(time_trace[5:95])
+    return [output]

+ 2 - 1
log2list_examples/create_measurement_list_bente.py

@@ -160,6 +160,8 @@ def custom_func(list_row: pd.Series, animal_tag: str) -> pd.Series:
 #extract odor and concentration from name
     (list_row["Odour"],list_row["OConc"]) = get_odorinfo_from_label(list_row["Label"])
     
+    if  list_row["Label"][-4:] == '.tif':
+            list_row["Label"] = list_row["Label"][:-4]
     
     return list_row
 
@@ -261,4 +263,3 @@ if __name__ == "__main__":
                                                 overwrite_old_values=overwrite_old_values)
 
 
-

+ 1 - 1
view/python_core/ctvs/__init__.py

@@ -438,7 +438,7 @@ def ctv_chunk_magnitude_basic(
 
 
 def get_custom_ctv_method(file, function_name):
-
+    
     with open(file, 'r') as fh:
         import scipy
         exec(compile(fh.read(), "<string>", "exec"), {"np": np, "scipy": scipy}, locals())

+ 2 - 5
view/python_core/measurement_list/importers.py

@@ -367,12 +367,9 @@ class P1DualWavelengthTIFSingleFileImporter(BaseImporter):
 
         return pd.DataFrame(lst_line).T
 
-    # for till data, a single raw data file is a .lsm file
+    # for till data, a single raw data file 
     def parse_metadata(self, fle: str, fle_ind: int,
                        measurement_filter: typing.Callable[[pd.Series], bool] = True) -> pd.DataFrame:
-
-
-#######
         # load metadata
         tif_file=pl.Path(fle)
         with tifffile.TiffFile(tif_file) as tif:
@@ -451,7 +448,7 @@ class P1DualWavelengthTIFSingleFileImporter(BaseImporter):
         UTC = measurementtime.timestamp()
         meta_info.update({'UTCTime':UTC})
         
-##example for meta_info: 
+##example for meta_info now: 
  #    {'ID': 'Pixels:1-0',
  # 'DimensionOrder': 'XYCTZ',
  # 'Type': 'uint16',