#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 //==================================================== // WAVE ORGANIZATION (Administrative) //==================================================== // ------------------------------------------------------------ // Function: prefix_detector // Purpose : Prompts the user for a wave prefix, verifies that // matching waves exist, stores the prefix, and // triggers the initial wave organization. // Inputs : User-entered wave prefix string. // Outputs : Stores Wave_prefix in the Packages folder. // Calls sorting_hat() to organize waves. // Notes : Depends on the currently active data folder. // ------------------------------------------------------------ Function prefix_detector() String prefix Prompt prefix, "Enter wave prefix:" DoPrompt "Wave selector", prefix if (V_Flag) LogWarn("prefix_detector: cancelled by user.") return 0 endif // Verify waves exist with the given prefix String list = WaveList((prefix + "*"), ";", "") if (ItemsInList(list) < 1) LogError("No waves found with prefix: " + prefix) return 0 endif // Store prefix in Packages folder String packages_path = GetDataFolder(1) + "Packages" NewDataFolder/O $(packages_path) String/G $(packages_path + ":Wave_prefix") = prefix LogInfo("Prefix set: " + prefix + " (" + num2str(ItemsInList(list)) + " waves found)") sorting_hat(prefix) End // ------------------------------------------------------------ // Function: sorting_hat // Purpose : Organizes raw waves into a two-level folder // hierarchy: channel (chan_X) and experiment (exp_X). // Inputs : prefix - wave name prefix to match // Notes : Runs first_phase (by channel) then second_phase // (by experiment) for each wave suffix type. // ------------------------------------------------------------ Function sorting_hat(prefix) String prefix String sufs = "_Amp;_Dur;*" Variable k // First phase: sort by channel for (k=0; k