diff --git a/data_processing.ipynb b/data_processing.ipynb index 9598e30..ebb52f8 100644 --- a/data_processing.ipynb +++ b/data_processing.ipynb @@ -330,7 +330,7 @@ "# Go back to root data folder\n", "os.chdir(path_data)\n", "\n", - "def smooth_data(data, window_size=40):\n", + "def smooth_data(data, window_size=50):\n", " \"\"\" Apply a simple moving average to smooth the data. \"\"\"\n", " return uniform_filter1d(data, size=window_size, mode='nearest')\n", "\n", @@ -371,14 +371,16 @@ " file_csv = os.path.join(path_results, f\"{subject}_acq-{shim_method}_T2starw_label-SC.csv\")\n", " df = pd.read_csv(file_csv)\n", " data_sc = df['WA()']\n", + " data_sc_smoothed = smooth_data(data_sc)\n", "\n", " # Get signal in CSF\n", " file_csv = os.path.join(path_results, f\"{subject}_acq-{shim_method}_T2starw_label-CSF.csv\")\n", " df = pd.read_csv(file_csv)\n", " data_csf = df['WA()']\n", + " data_csf_smoothed = smooth_data(data_csf)\n", " \n", " # Compute ratio\n", - " data_sc_csf_ratio = data_csf / data_sc\n", + " data_sc_csf_ratio = data_csf_smoothed / data_sc_smoothed\n", "\n", " # Normalize the x-axis to a 0-1 scale for each subject\n", " x_subject = np.linspace(0, 1, len(data_sc_csf_ratio))\n", @@ -387,10 +389,7 @@ " interp_func = interp1d(x_subject, data_sc_csf_ratio, kind='linear', bounds_error=False, fill_value='extrapolate')\n", " resampled_data = interp_func(x_grid)\n", "\n", - " # Apply smoothing\n", - " smoothed_data = smooth_data(resampled_data)\n", - "\n", - " method_data.append(smoothed_data)\n", + " method_data.append(resampled_data)\n", "\n", " # If there's data for this shim method, plot it\n", " if method_data:\n",