IDL_flags.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon May 28 16:48:33 2018
  4. @author: Giovanni Galizia
  5. """
  6. # all flags from IDL now as lists
  7. import pandas as pd
  8. import os
  9. def IDL_default_flags(STG_MotherOfAllFolders=''):
  10. # this version taken from master_jacob_sorted.pro
  11. # if STG_MotherOfAllFolders is empty, then current working directory is used
  12. #, sample master file
  13. #, containing all available flags as of september 2008
  14. #, sorted in logical groups
  15. #, note, however, that not all flag settings are mentioned
  16. #, you still need to know what you can do and what the program does
  17. #, and you still need to run the necessary constrols
  18. # ALL IDL flags are in here now,
  19. # ALSO those that were not called flags
  20. # and the Movie flags also
  21. # however - all commented out. Only free those that are being used
  22. # in order to keep track of the new code
  23. if STG_MotherOfAllFolders == '':
  24. STG_MotherOfAllFolders = os.getcwd()
  25. IDL_flag = pd.Series({
  26. ## system flags, many not necessary for the python version
  27. "VIEW_batchmode": 1, # choice between interactive mode and VIEW_batchmode
  28. # "MacSystem": "deprecated",
  29. ## format flags, not all necessary for python version
  30. # "TrueColour": 1,
  31. "SO_MV_colortable": 13,
  32. ##
  33. ##,*****************************
  34. ##,flags related to LOADING DATA
  35. ##,*****************************
  36. ##
  37. ## ,format of data files (used in LoadDataMaster.pro)
  38. "LE_loadExp" : 3, #20, # 3,4 , 0 for old setup, to 1 for Visicam, 2 for confocal
  39. ## ,TILL photonics single wavelength: 3
  40. ## ,TILL photonics dual wavelength (FURA): 4
  41. ## ,ZEISS multiphoton data: 20
  42. ##
  43. ## ,should the raw data be median filtered? (used in ViewLoadData\MedianCorrection.pro)
  44. "Data_Median_Filter" : 0, #in ViewLoadData.MedianCorrection
  45. ## ,do a median correction when loading the data
  46. ## ,0: no median
  47. ## ,1: median in space fixed values
  48. ## ,2: median in time fixed values
  49. ## ,3: median in space and time, using flag values (Data_Median_Filter_space)(Data_Median_Filter_time)
  50. "Data_Median_Filter_space": 3,
  51. ## , used with Data_Median_Filter eq 3
  52. "Data_Median_Filter_time": 0,
  53. ## , used with Data_Median_Filter eq 3
  54. ##
  55. ## ,apply an off-line binning (shrinkFaktor).
  56. "LE_ShrinkFaktor": 0, # ,no shrinkfaktor with 1
  57. ##
  58. ## ,are there different focal depth to be split?
  59. # "RM_separateLayers": 0,
  60. ## ,separates the layers in exportGlomeruli and SingleOverviews
  61. ##
  62. ## ,how to make movement correction based on .moveList file. (used in ViewLoadData\MovementCorrectionMaster.pro)
  63. "CSM_Movement": 0,
  64. ## ,set to 0: no movement correction (BUT shifts from .lst file are USED!)
  65. ## ,set to 1: on the spot movement correction
  66. ## ,set to 2: as 1, but calculated movements are saved in the moveList file
  67. ## ,set to 3: movement values are read from the moveList file
  68. ## ,set to 5: no movement correction, but shifts are taken from the movement file
  69. ## ,values above 10: mathiasCorrection.
  70. # "CSM_DataShift": 0,
  71. ## ,set to 0: data is NOT shifted, coordinates ARE shifted
  72. ## ,set to 1: data IS shifted, coordinate are NOT shifted
  73. ## ,set to 2: NONE is shifted
  74. ##
  75. ## ,trim the data frames to be loaded
  76. ## ,remove n frames at the beginning of each measurement
  77. # "CSM_SkipFrmUpFront": 0,
  78. ## ,remove n frames at the end of each measurement
  79. # "CSM_SkipFrmAtBack": 0,
  80. ##
  81. ## ,settings to reduce memory usage
  82. # "VIEW_No4Darray": 1,
  83. ## ,this reduces the sig1 array to a 3D array instead of a 4D array, not all routines work with this setting
  84. ## ,set to 1: odor 0 is cut off memory after loading the data, p1.odors is reduced by 1
  85. #### Python: implement single odor use only, for now
  86. #### therefore VIEW_No4Darray is 1 by default
  87. #### sig1 is (x,y,t) and not (x,y,t,o)
  88. ##
  89. "VIEW_DeleteRawData": 0,
  90. ## ,this removes the raw data from memory after loading
  91. ##
  92. ## ,correct for scattered light, improving spatial resolution (used in CalcSigAll3000.pro)
  93. "VIEW_ScatterLightFactor": 0,
  94. ## ,for the 3xyy and 4xyy family with scattered light correction, this factor gives the strength of the unsharp mask. Default: 1
  95. ## ,only used if (yy ne 00)
  96. ##
  97. ## ,load more than one experiment at the time
  98. # "view_MultiExp": 0, # , 0 for single experiment
  99. ## ,load AIR trial alongside the odor response (air trial is given in control column in the .lst file)
  100. "LE_AskForAir": 0, # , 0 for not loading air
  101. ##
  102. ##,END of flags related to loading data
  103. ##
  104. ##
  105. ##,************************************
  106. ##,flags related to CALCULATING SIGNALS
  107. ##,************************************
  108. ##
  109. ## ,how to calculate the data (used in ViewCalculateData\CalcSigMaster.pro)
  110. "LE_CalcMethod" : 4900, #see calcsigmaster3000
  111. ## ,family 3xyy (deltaF/f) and 4xyy (ratio) uses x for bleach correction settings, and yy for scattered light correction
  112. ## ,see CalcSigAll3000.pro for detailed settings. Example are:
  113. ## , setting: 0 1 2 3 4 5 6 7 8 9
  114. ## ,alPerimeter + + + + - - - - C - , with 8 bleaching is in coordinates only (variable: CoorPerimeter)
  115. ## ,excludeStim - + - + - + - + - - , exclude stimulus is obsolete - controled by LE_BleachStartFrame group
  116. ## ,addNoise - - + + - - + + - -
  117. ## ,no bleach - - - - - - - - - +
  118. ## ,air bleach - - - - - - - - + - ,correct with bleach parameters taken from air trial
  119. ## ,set to 3 for no calculation (original data).
  120. ##
  121. ## ,which frames to use for calculating F in deltaF/F
  122. "LE_StartBackground" : 4,# for deltaF/F calculations, or bleach corrections
  123. ## ,set to -1 not to subtract background in data calculation, to frame for background start. Default: 4
  124. "LE_PrestimEndBackground" : 1, # for deltaF/F calculations, or bleach corrections
  125. ## ,How many frames before stimulus to stop with background. Default: 2
  126. ## ,so: background is calculated from LE_StartBackground to StimulusOn - LE_PrestimEndBackground
  127. ## ,that means that StimulusOn is an important parameter and needs to be set correctly for deltaF/F
  128. ##
  129. ## ,settings for bleach correction when using CalcSigAll3000
  130. "LE_BleachStartFrame" : 1, #start bleaching correction here
  131. ## ,for logarithmic bleach correction, all frames smaller are excluded in the fit function
  132. ## ,used in CalcSigAll3000, default 2
  133. "LELog_InitialFactor" : 3, # weigh the frames before stimulus more than those after stimulus
  134. ## ,for logarithmic bleach correction, all frames before stimulus onset are more important by this factor
  135. ## ,used in CalcSigAll3000, default 1 for maximum compatibility
  136. "LELog_ExcludeSeconds" : 6, #how many seconds should be excluded during stimulation for bleach log fitting?
  137. ## ,for logarithmic bleach correction, how many seconds after stimulus onset to exclude
  138. ## ,used in CalcSigAll3000, default 0 for maximum compatibility
  139. ## ,this uses the time information - therefore make sure that is correct
  140. ## ,graphic display of weights can be switched of and on in the program CalcSigAll3000
  141. # "LE_ClipPixels" : -2000, #how many seconds should be excluded during stimulation for bleach log fitting?
  142. ##
  143. ##,END of flags related to calculating signals
  144. ##
  145. ##
  146. ##,************************************
  147. ##,flags related to SIGNAL CORRECTIONS
  148. ##,************************************
  149. ##,note: this is for the extra set of corrected signals, not for corrections done during loading or calculation
  150. ##
  151. ##
  152. # "VIEW_InitCorr" : -1 ,# 18 : inverted (Fura at 810nm). set to -1 in order not to create a corrected data set
  153. # "VIEW_CorrSignals" : 0 ,# set to 1 to access corrected dataset, to 0 to access original data set
  154. ##
  155. ##
  156. ##
  157. ##,*************************************
  158. ##,flags related to data analysis OUTPUT
  159. ##,*************************************
  160. ##
  161. "VIEW_ReportMethod" : 10 , #which output do you want? This is one of the main flags
  162. ## , all settings are in View_gr_reports\subloop_report.pro, the most often used are
  163. ## , 10: false-color coded pictures (calls reportTIFF)
  164. ## , 11, 111: glodatamix (without, with tags)
  165. ## , 12: movies
  166. ## , 15: single TIFFs
  167. ## , 19: 119: glodatamix with CTV (without, with tags)
  168. ##
  169. "CTV_Method" : 22 , #curve-to-value function for single number output or still images
  170. ## , 22 gives
  171. ## , 22 is the difference between two fixed points
  172. ## , 35 relates to the maximum within 3 secs after stimulus onset
  173. ## , all values in ViewOverview\CurveToValue
  174. ## , values below 0 go to personal program in ImageALlocal folder: CurveToValueLocal.pro
  175. # "CTVM_Method" : 0,# , for multiple CTV values at once, not safely implemented yet
  176. ##
  177. ## "firstframe" was not in flags
  178. "CTV_firstframe" : 18 ,# many CTVs use fixed frames. These use the variables firstFrame and lastFrame
  179. "CTV_lastframe" : 22 , #for example, CTV 22 calculates the difference between lastframe (3 frames) and firstframe (3 frames)
  180. ##
  181. # "LE_FirstBuffer" : 1 , #sets which buffer to start with in output routines
  182. ## , standard is 1. Set to 0 to start with 0 (generally 0 is empty)
  183. ## , instead of LE_firstbuffer you can use LE_usefirstbuffer (synonymous)
  184. ##
  185. ## ,old flags, currently out of fashion
  186. # "PTA_PlotTimeRange" : 0,#
  187. # "PTA_PlotMeanValue" : 0,#
  188. ##
  189. ## ,flags specifically for graphical output (TIFF files and the like, i.e. "overviews")
  190. "SO_Method" : 10 , #used in ViewOverview\Overview.pro. Only values 0 or 10 are used now
  191. ## , 0 for calculations pixel by pixel (i.e. on the time-course in each pixel)
  192. ## , 10 for calculations frame by frame (much faster, but not all functions are possible)
  193. ## , for 10, the CTV value is applied within ViewOverview\overview10ctv.pro
  194. "SO_individualScale" : 0,# what scaling to use? 0 for fixed values, else individual scale for each frame
  195. ## , 3 for scaling within center of each frame
  196. ## , can be used in quite sophisticated ways, see ViewOverview\SingleOverviews.pro
  197. ## , also explained in the documentation
  198. ## "SO_MV_scalemax" was not in flags
  199. "SO_MV_scalemax": 18.000 ,# value to scale maximum to with SO_indiScale equals 0
  200. "SO_MV_scalemin": -5.000 ,# corresponding value for minimum
  201. ##
  202. # "SO_morphoBackgr" : 0 , #Used to show an anatomical picture with an overlay of only the strongest POSITIVE responses
  203. # "SO_morphoBackgrNeg" : 0 , #Used to show an anatomical picture with an overlay of only the strongest NEGATIVE responses
  204. "SO_withinArea" : 1 , #False-color output limited to the mask in the .area file
  205. ##
  206. "CTV_scalebar" : 1 , #some output options allow to print out the color scalebar (SingleOverviews.pro)
  207. "RM_fotook" : 0 , #Overlay other information to overview output, (SingleOverviews.pro)
  208. ## , 1: puts squares in the coordinate positions (from .coor file)
  209. ## , 5: shows the perimeter of the .area file
  210. # "RM_differentViews" : 0 ,# Change view, e.g. mirror flip right ALs (SingleOverviews.pro)
  211. "RM_unsharpmask" : False , #Post-hoc filter on false-color images (SingleOverviews.pro)
  212. ##
  213. "RM_NewColumn" : 1 , #Start a new column in "tapeten" output (SingleOverviews.pro)
  214. ## , this flag is generally set in the gr_XXX file
  215. ##
  216. ## ,old flags
  217. # "RM_PlotTrace" : 0 ,#
  218. # "RM_PrintAscii" : 0 ,#
  219. # "RM_PrintLine" : 1 ,#
  220. "RM_ROItrace" : 0 ,# to select area file in exportglomeruli
  221. "RM_nextposition" : [0,0], #position of a frame in output canvas
  222. ##
  223. ##
  224. ## ,flags for filters
  225. "RM_Radius" : 5 , #For calculating traces (glodatamix), or for some spatial filters
  226. #used in CalcSigAll3000, also singleoverviews
  227. ## "Signal_FilterSpaceFlag" was not in flags
  228. "Signal_FilterSpaceFlag" : 1 , #If set to 1, the signal is calculated on the time trace at each pixel
  229. ## , after taking the mean of the pixels around it (RM_Radius). Therefor this is a slow filter
  230. ## , If set to 0, this filter is switched off
  231. "Signal_FilterSpaceSize" : 3 , #Filter size applied after overview calculation, always.
  232. ## , set to 0 when Signal_FilterSpaceFlag is on, to avoid double filtering.
  233. "Signal_FilterTimeFlag" : 1 , #Switch for the temporal filter
  234. "Signal_FilterTimeSize" : 3 ,# Size of the temporal filter
  235. ##
  236. ##
  237. ##,*******************************************
  238. ##,flags to control PATHS for input and output
  239. ##,*******************************************
  240. ##
  241. ## , this is one standard arrangement of folders
  242. ## , just adapt the STG_MotherOfAllFolders, but all subfolders must exist
  243. ## , place where all files are
  244. "STG_MotherOfAllFolders": STG_MotherOfAllFolders , #
  245. ##
  246. ##
  247. "STG_ReportTag" : 'animal' , #this contains the animal flag, set this for each round and animal, ( jacob: if not using the gr_xxx method)
  248. ## , this is set within the gr_file
  249. "STG_Measu" : 0, # measurement tag in .lst file [added in Python]
  250. ##
  251. ## , folder for the data files, STG_MotherOfAllFolders added below
  252. #### "STG_Datapath": STG_MotherOfAllFolders + 'data_jacob_LSM\'
  253. "STG_Datapath" : os.path.join(STG_MotherOfAllFolders, 'data'),
  254. ## , folder for the .inf files
  255. "STG_OdorInfoPath" : os.path.join(STG_MotherOfAllFolders, 'Lists'),
  256. ## , folder for the .coor and the .area file
  257. "STG_OdormaskPath" : os.path.join(STG_MotherOfAllFolders, 'Coor'),
  258. ## , folder for the all OUTPUT files
  259. "STG_OdorReportPath": os.path.join(STG_MotherOfAllFolders, 'IDLoutput'),
  260. ## , folder for the all OUTPUT files
  261. "STG_OdorReportFile": 'XYZ',
  262. ## , can be used for any text
  263. # "STG_Missing" : '999',
  264. ##
  265. ##
  266. ##,************************************
  267. ##,flags used for MOVIE output
  268. ##,************************************
  269. ##
  270. ##, in interactive mode, these flags are overwritten by the values in
  271. ##, imageALlocal\SetExportMovieFlags.pro
  272. ##, the variables are defined in view.pro
  273. ##
  274. "mv_exportFormat" : 'stack_tif' ,#'mpg4', #3 ,# 1 for TIFF (single files), 2 for PICT (premiere), 3 for MPEG, 4 for multilayer GIF, 5: multilayer TIF
  275. ## , 6 for uncompressed AVI (generally the best)
  276. # in python, mv_exportformat is not with numbers any more, but with strings
  277. "mv_realTime" : 1 ,# insert frames per second, 0 for no realTime, 24 for MPEG, 15 for GIF->QuickTime
  278. ## , AVI can work with any time, therefore 0 IS realTIME. In the other formats, additional frames are invented to create real time
  279. ## , if a negative number is given, that many frames are removed
  280. "mv_SpeedFactor" : 1 ,# for exportFormat 6, increase or decrease speed of movie
  281. "mv_reverseIt" : 0 , #turn it upside down
  282. "mv_rotateImage" : 0 ,# rotate only image, , 0 for no action, 2 for 180 degrees
  283. "mv_cutborder" : 0 ,# how many pixels to cut from each side (border, to hide filter artefacts)
  284. "mv_morphoThreshold" : 0 ,# substitutes lower range with morphological image to be taken from file
  285. "mv_withinArea" : 0 ,# limits output to within the mask in xxx.area
  286. "mv_sdSignificanceCut" : 0 ,# cuts everything below that significance level. Stimulus is included in calculation, ignored if below 0.1.
  287. ## , , Not implemented yet
  288. "mv_markStimulus" : 1 ,# marks stimulus application with a red box
  289. "mv_percentileScale" : False ,# scaling to a percentaje of noise. don´t use
  290. "mv_individualScale" : 2 ,# follows a similar logic to ("so_indiScale")
  291. ## ,0, 1: Pixmin and Pixmax are taken
  292. ## ,2 : min and maximum of sequence is taken
  293. ## ,3 : min and max of central region is taken
  294. ## ,4 : max of sequence is taken, min is Pixmin
  295. ## ,5 : min and max from area region
  296. ## ,6 : min from pixmin, max from area
  297. ## ,7 : min from pixmin, max from area but only stimulus + 2*stimulus length
  298. ##
  299. "mv_indiScale3factor" : 0.2 ,# set to 0.2 for 20 % border to be ignored when scaling usind idividualscale eq 3
  300. ## , for mv_individualScale above 100
  301. "mv_percentileValue" : 0 ,# : float(individualScale MOD 100)/100.0
  302. "mv_xgap" : 50 ,# vertical + horizontal gaps, only even numbers!
  303. "mv_ygap" : 50 ,# 6, 10
  304. "mv_correctStimulusOnset" : 0 ,# value to be added to stimulus onset (in frames)
  305. "mv_displayTime" : True ,# time in ss:ms as figures
  306. "mv_minimumBrightness" : 0 ,# creates a mask that depends on the brightnes of the foto
  307. "mv_suppressMilliseconds" : True,
  308. ##
  309. ##
  310. ## ,these flags are for interactive use in view (fasttraces)
  311. ## ,but are also used in movies to select a frame range for movie output
  312. ## ,set both to -1 to calculate the entire movie, else to fixed frame numbers
  313. "FT_FirstFrame" : -1 ,# show trace subsed in fast traces in VIEW
  314. "FT_LastFrame" : -1 ,# show trace subsed in fast traces in VIEW
  315. #the Ajay programs do not use FT_FirstFrame, but mv_FirstFrame, and more
  316. "mv_FirstFrame" : -1 ,# show trace subsed in fast traces in VIEW
  317. "mv_LastFrame" : -1 ,# show trace subsed in fast traces in VIEW
  318. "mv_bgColor" : 'b' ,
  319. "mv_bitrate": '1024k',
  320. # values are 'single_tif', 'stack_tif', 'libx264' or other codecs
  321. "mv_fgColor": 'w'
  322. ##
  323. ## ,flags that are also relevant for movies, do NOT change them here to avoid confusion, change them above
  324. ## ,check program viewoverview\Exportmovie
  325. ## ,"ctv_scalebar"
  326. ## ,scaleMin
  327. ## ,scaleMax
  328. ## ,filterSpaceFlag
  329. ## ,filterSpaceSize
  330. ## ,SO_MV_colortable
  331. ## ,FILENAME defined in localOdorText
  332. ##,end of movie settings
  333. ##
  334. ##
  335. ##
  336. ##,************************************
  337. ##,flags NOT USED for off-line analysis
  338. ##,************************************
  339. ##
  340. ## "LE_ShowBox" : 0 ,
  341. ## "FT_AllOdors" : 0 , show all odor traces in fast traces in VIEW
  342. ## "FT_TimeXAxis" : 0 , show time as x-axis in fast traces in VIEW
  343. ## "FT_Subset" : 0 , show trace subsed in fast traces in VIEW
  344. ## "FT_SelectFrame" : 0 , show trace subsed in fast traces in VIEW
  345. ##
  346. ##
  347. ##,"VIEW_InitCorr" : -1 , erase this line after analysis of these animals
  348. ##, "STG_OdorReportPath" : STG_MotherOfAllFolders + 'IDL_jacob_glomInteraction\IDLoutput\movies\j080730b\'
  349. ##,gr_takefromlist, 'j080730b',2
  350. ##, "STG_OdorReportPath" : STG_MotherOfAllFolders + 'IDL_jacob_glomInteraction\IDLoutput\movies\j080730c\'
  351. ##,gr_takefromlist, 'j080730c',2
  352. })
  353. # here: change STG paths to add "mother of all directories" to it
  354. #test
  355. return IDL_flag
  356. #########################################################
  357. ########## Main starts here
  358. #########################################################
  359. #define flag structure
  360. IDL_flag = IDL_default_flags('') # can also be called with empty brackets()
  361. # end of program