From 3de05e74634b5f13d2fbc70ae6f28d39a48e14a7 Mon Sep 17 00:00:00 2001
From: Chirsophe <cbsmith2@uab.edu>
Date: Mon, 10 Mar 2025 19:21:15 -0500
Subject: [PATCH] Label transfer complete.

---
 .gitignore           |  1 +
 SaveTranscriptions.m | 63 ++++++++++++++++++++++++++------------------
 2 files changed, 39 insertions(+), 25 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..21229f7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.asv
\ No newline at end of file
diff --git a/SaveTranscriptions.m b/SaveTranscriptions.m
index efb41fc..10fba75 100644
--- a/SaveTranscriptions.m
+++ b/SaveTranscriptions.m
@@ -1,36 +1,49 @@
-% I am not happy with how these files work
-
-
-% 1. load in the transcribed file + the original
-% 2. Purge the labels from the original
-    % resetLabelValues(lss)
-% 3. Copy the transcribed labels to the original
-    % setLabelValue?
-
-% For testing
+%% For testing
 load('C:\Users\chris\Box\Nelson Lab Data\Other Data\NTAud Transcription\Transcript_OrigAudio_AudSentStim.mat', 'lss');
 test = load('C:\Users\chris\Box\Nelson Lab Data\Other Data\NTAud Transcription\Transcript_Version2_AudSent.mat');
 ls = test.lss;
 
-% Search the workspace for ls and lss
+%% Main code
+% Search the workspace for ls and lss and check for the tracker
+if ~ValidWorkspace(ls, lss); return; end
 
-% Remove labels for lss
-resetLabelValues(lss)
+% Update progress
+    % Compare ls and lss roi and values
 
-% Relable lss using ls
-nTrials = height(test.lss.Labels);
-for iTrial = 1:nTrials
-    nWords = height(test.lss.Labels.Words{iTrial});
-    setLabelValue(lss, iTrial, 'Words', test.lss.Labels.Words{iTrial}.ROILimits, test.lss.Labels.Words{iTrial}.Value)
+% Transfer labels
+lss = TransferLabels(ls, lss);
+
+% Save lss and progress
+    % use uiget element to select save location
+
+%% Functions
+function extStatus = ValidWorkspace(ls, lss)
+
+if ~exist("ls", "var")
+    fprintf(2, 'No exported transcript found. Please export your transciription to the work space as ''ls''\n')
+    extStatus = false;
+    return
 end
 
-% 
+if ~exist("lss", 'var')
+    fprintf(2, 'The original transcription file is missing, please ensure the work you have done is saved to ''ls'' and load in the original transcription\n');
+    extStatus = false;
+    return
+end
+
+extStatus = true;
+
+end
 
-% Code will be run after student saves the file to the workspace
-    % Check workspace to find ls, lss, and 
+function lss = TransferLabels(ls, lss)
 
-% add functionality to check if sessions have been edited compare ROI and
-% script
+% Clear lss labels
+resetLabelValues(lss)
+
+% Move ls labels to lss
+nTrials = height(ls.Labels);
+for iTrial = 1:nTrials
+    setLabelValue(lss, iTrial, 'Words', ls.Labels.Words{iTrial}.ROILimits, ls.Labels.Words{iTrial}.Value)
+end
 
-% Save the file and save the current progress
-    % Use a uiget element to delect save location
+end
\ No newline at end of file
-- 
GitLab