OSCR

Assessing adverse effects and unspecific effects of transcutaneous spinal direct current stimulation (tsDCS).

Code ↔ Paper

5 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

5 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 5 matches
  1. [1] § Materials and Methods › Data processing › UEs › Respiratory activity ↔ UE_analysis_4_respiration.py, lines 4 to 63 · score 0.94 · representing maximum inhalation, breathing cycle, consecutive breaths, standard deviation, breathing rate variability, signal minima · block oscr:b:QFNRK8CWEHRFQ-6 · Report a mismatch
  2. [2] § Materials and Methods › Data processing › UEs › Skin conductance fluctuations (SCF) ↔ UE_analysis_2_SCF.py, lines 4 to 63 · score 0.90 · Butterworth bandpass, baseline signal, skin conductance, SCF, 0.0159 Hz, quantified · block oscr:b:F6CGQRWZW3028-8 · Report a mismatch
  3. [3] § Materials and Methods › Data processing › UEs › Electrocardiographic (ECG) activity ↔ UE_analysis_3_ECG.py, lines 4 to 73 · score 0.76 · heart beats, heart rate variability, py, square, root, ecg · block oscr:b:JWSQE6AGAN4G9-S · Report a mismatch
  4. [4] § Materials and Methods › Statistical analysis › UEs ↔ UE_analysis_5_outlier.py, lines 4 to 28 · score 0.75 · abnormal signal fluctuations, participants autonomic, inadvertently, instructed, administration, tsDCS · block oscr:b:44002FK1NXXRS-T · Report a mismatch
  5. [5] § Materials and Methods › Data processing › UEs › Electrocardiographic (ECG) activity ↔ UE_analysis_1_prep.py, lines 4 to 68 · score 0.62 · Pan Tompkins Algorithm, beats, ecg, peaks · block oscr:b:E8F7YV9HN30SR-J · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 480 lines · 22 KB · no license · 1 match

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Description:
  5. ------------
  6. This script analyzes the respiratory activity.
  7. First we cut the data according to the information saved using a_tsdcs_UE_analysis_prep.py.
  8. The time points that mark the beginning of a new breathing cycle are automatically detected
  9. as signal minima represent maximum inhalation.
  10. We then extract the breathing rate (breaths per minute) and breathing rate variability
  11. (standard deviation of the interval between consecutive breaths) over the whole interval
  12. and within the 4 quartiles.
  13. In the unblinding step the session-condition mapping is read and
  14. outliers are excluded. The resulting table BR_BDev_unblind.csv can be used
  15. for statistical analysis and further plotting.
  16. The within-subject plots (fig 4D and 4E) are created.
  17. Additionally, an interaction plot (fig 4F) is created.
  18. Authors:
  19. --------
  20. Ulrike Horn
  21. Contact:
  22. --------
  23. [email hidden]
  24. Date:
  25. -----
  26. 20th November 2023
  27. """
  28. import mne
  29. import numpy as np
  30. import pandas as pd
  31. import os
  32. import glob
  33. import json
  34. from scipy import signal, stats
  35. import matplotlib as mpl
  36. mpl.use('TkAgg')
  37. import matplotlib.pyplot as plt
  38. import seaborn as sns
  39. raw_path = '/data/pt_02582/tsDCS_BIDS/'
  40. output_path = '/data/pt_02582/tsDCS_processed/'
  41. result_path = '/data/pt_02582/tsDCS_results/Resp/'
  42. if not os.path.exists(output_path):
  43. os.makedirs(output_path)
  44. if not os.path.exists(result_path):
  45. os.makedirs(result_path)
  46. new_sr = 100 # Hz that data will be downsampled to
  47. tasks = ['tsDCS']
  48. subjects = ['SR01', 'SR02', 'SR03', 'SR04', 'SR05', 'SR06', 'SR07', 'SR08', 'SR09', 'SR10',
  49. 'SR11', 'SR12', 'SR13', 'SR14', 'SR15', 'SR16', 'SR17', 'SR18', 'SR19', 'SR20']
  50. sessions = [1, 2, 3]
  51. preprocess = True
  52. save_markers = True
  53. unblinding = True
  54. within_sub_plot = True
  55. interaction_plot = True
  56. np.random.seed(1990) # for jitter
  57. color_blue = [0, 128/255, 255/255]
  58. color_red = [227/255, 0, 15/255]
  59. color_orange = [239/255, 138/255, 16/255]
  60. new_rc_params = {"font.family": 'Arial', "font.size": 12, "font.serif": [],
  61. "svg.fonttype": 'none'}
  62. mpl.rcParams.update(new_rc_params)
  63. bpm_all = []
  64. dev_all = []
  65. bpm_Q1 = []
  66. dev_Q1 = []
  67. bpm_Q2 = []
  68. dev_Q2 = []
  69. bpm_Q3 = []
  70. dev_Q3 = []
  71. bpm_Q4 = []
  72. dev_Q4 = []
  73. for isub in subjects:
  74. sub = 'sub-' + isub
  75. print('subject {}'.format(isub))
  76. for ses in sessions:
  77. for task in tasks:
  78. physio_files = glob.glob(raw_path + sub + os.sep + 'ses-' + str(ses) + os.sep + 'beh' + os.sep + '*' + task + '*_emg.vhdr')
  79. physio_files = np.array(sorted(physio_files))
  80. if len(physio_files) > 1:
  81. print('Warning! More than one file found!')
  82. sub_out_path = output_path + sub + os.sep + 'ses-' + str(ses) + os.sep + 'Resp'
  83. if not os.path.exists(sub_out_path):
  84. os.makedirs(sub_out_path)
  85. if preprocess:
  86. p = physio_files[0]
  87. # import raw data with MNE
  88. raw = mne.io.read_raw_brainvision(p, preload=True)
  89. sr = raw.info['sfreq']
  90. # pick respiration channel
  91. raw.pick_channels(ch_names=["RES"])
  92. # get events file
  93. tmp = p.split('_emg')
  94. event_file = tmp[0] + '_events.tsv'
  95. events = pd.read_table(event_file, sep='\t')
  96. # cut data from manually inserted event
  97. onset = events.loc[events['value'] == 'manual', 'onset'].values[0]
  98. duration = events.loc[events['value'] == 'manual', 'duration'].values[0]
  99. if onset + duration >= len(raw) / sr:
  100. raw.crop(tmin=onset, tmax=None, include_tmax=True)
  101. else:
  102. raw.crop(tmin=onset, tmax=onset + duration, include_tmax=True)
  103. raw_plot = raw.get_data() # convert object to numpy array of shape (n_channels, n_times)
  104. raw_plot = np.squeeze(raw_plot) # get rid of dimension "n_channels" -> (rows: time points)
  105. # inhalation starts = min peaks, so invert data
  106. raw_plot = 1 - raw_plot
  107. median_height = np.median(raw_plot)
  108. inhale_peaks, properties = signal.find_peaks(raw_plot, height=median_height, distance=1.0 * sr, width=0.5 * sr)
  109. # how many breaths per minute?
  110. bpm = len(inhale_peaks) / (len(raw_plot) / sr / 60)
  111. bpm_all.append(bpm)
  112. # how much deviation is in the peaks
  113. dev = np.std(np.diff(inhale_peaks))/sr
  114. dev_all.append(dev)
  115. # same for 5 minute blocks
  116. len_quart = int(np.floor(len(raw_plot)/4))
  117. inhale_peaks_1 = np.delete(inhale_peaks, inhale_peaks > len_quart)
  118. bpm_1 = len(inhale_peaks_1) / ((len(raw_plot)/4) / sr / 60)
  119. bpm_Q1.append(bpm_1)
  120. dev_1 = np.std(np.diff(inhale_peaks_1)) / sr
  121. dev_Q1.append(dev_1)
  122. inhale_peaks_2 = np.delete(inhale_peaks, (inhale_peaks < len_quart) | (inhale_peaks > 2 * len_quart))
  123. bpm_2 = len(inhale_peaks_2) / ((len(raw_plot) / 4) / sr / 60)
  124. bpm_Q2.append(bpm_2)
  125. dev_2 = np.std(np.diff(inhale_peaks_2)) / sr
  126. dev_Q2.append(dev_2)
  127. inhale_peaks_3 = np.delete(inhale_peaks, (inhale_peaks < 2 * len_quart) | (inhale_peaks > 3 * len_quart))
  128. bpm_3 = len(inhale_peaks_3) / ((len(raw_plot) / 4) / sr / 60)
  129. bpm_Q3.append(bpm_3)
  130. dev_3 = np.std(np.diff(inhale_peaks_3)) / sr
  131. dev_Q3.append(dev_3)
  132. inhale_peaks_4 = np.delete(inhale_peaks, inhale_peaks < 3 * len_quart)
  133. bpm_4 = len(inhale_peaks_4) / ((len(raw_plot) / 4) / sr / 60)
  134. bpm_Q4.append(bpm_4)
  135. dev_4 = np.std(np.diff(inhale_peaks_4)) / sr
  136. dev_Q4.append(dev_4)
  137. if save_markers:
  138. rep_subjects = subjects * 3
  139. rep_subjects_prefix = ['sub-' + subject for subject in rep_subjects]
  140. markers = pd.DataFrame({'BPM': bpm_all, 'BDev': dev_all,
  141. 'BPM_Q1': bpm_Q1, 'BPM_Q2': bpm_Q2, 'BPM_Q3': bpm_Q3, 'BPM_Q4': bpm_Q4,
  142. 'BDev_Q1': dev_Q1, 'BDev_Q2': dev_Q2, 'BDev_Q3': dev_Q3, 'BDev_Q4': dev_Q4,
  143. 'Subject': rep_subjects_prefix,
  144. 'Session': np.resize(np.arange(1, 4), len(subjects)*3)})
  145. markers.to_csv(result_path + 'BPM.csv', sep=',', index=False)
  146. if unblinding:
  147. def adjust_box_widths(g, fac):
  148. """
  149. Adjust the withs of a seaborn-generated boxplot.
  150. """
  151. # iterating through Axes instances
  152. for ax in g.axes:
  153. # iterating through axes artists:
  154. for c in ax.get_children():
  155. # searching for PathPatches
  156. if isinstance(c, PathPatch):
  157. # getting current width of box:
  158. p = c.get_path()
  159. verts = p.vertices
  160. verts_sub = verts[:-1]
  161. xmin = np.min(verts_sub[:, 0])
  162. xmax = np.max(verts_sub[:, 0])
  163. xmid = 0.5 * (xmin + xmax)
  164. xhalf = 0.5 * (xmax - xmin)
  165. # setting new width of box
  166. xmin_new = xmid - fac * xhalf
  167. xmax_new = xmid + fac * xhalf
  168. verts_sub[verts_sub[:, 0] == xmin, 0] = xmin_new
  169. verts_sub[verts_sub[:, 0] == xmax, 0] = xmax_new
  170. # setting new width of median line
  171. for l in ax.lines:
  172. if np.all(l.get_xdata() == [xmin, xmax]):
  173. l.set_xdata([xmin_new, xmax_new])
  174. df = pd.read_csv(result_path + 'BPM.csv', sep=',', header=0)
  175. rand_df = pd.read_csv('/data/pt_02582/tsDCS_BIDS/participants.tsv', sep='\t')
  176. def replace_cond(row):
  177. this_sub = row['Subject']
  178. this_rand = rand_df[rand_df['participant_id'] == this_sub]
  179. if row['Session'] == 1:
  180. val = this_rand['condition_ses-1'].values[0]
  181. elif row['Session'] == 2:
  182. val = this_rand['condition_ses-2'].values[0]
  183. elif row['Session'] == 3:
  184. val = this_rand['condition_ses-3'].values[0]
  185. else:
  186. print('something weird happened')
  187. return val
  188. df['Condition'] = df.apply(replace_cond, axis=1)
  189. # exclude the subjects' sessions that we decided on:
  190. df.loc[(df['Subject'] == 'sub-SR01') & (df['Session'] == 2), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  191. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  192. df.loc[(df['Subject'] == 'sub-SR08') & (df['Session'] == 2), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  193. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  194. df.loc[(df['Subject'] == 'sub-SR09'), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  195. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  196. df.loc[(df['Subject'] == 'sub-SR10') & (df['Session'] == 3), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  197. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  198. df.loc[(df['Subject'] == 'sub-SR13'), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  199. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  200. df.loc[(df['Subject'] == 'sub-SR14'), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  201. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  202. df.loc[(df['Subject'] == 'sub-SR16') & (df['Session'] == 3), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  203. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  204. df.loc[(df['Subject'] == 'sub-SR17') & (df['Session'] == 3), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  205. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  206. df.loc[(df['Subject'] == 'sub-SR19') & (df['Session'] == 1), ['BPM', 'BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  207. 'BDev', 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4']] = np.nan
  208. # make a plot
  209. sns.set_context("talk")
  210. hue_order = ['A', 'C', 'B']
  211. fig, axes = plt.subplots(2, 1)
  212. fig.suptitle('Breathing rate and breathing rate variability', fontsize=16)
  213. sns.boxplot(df, x='Condition', y='BPM', order=hue_order,
  214. ax=axes[0], boxprops={'alpha': 0.4}, showfliers=False)
  215. sns.stripplot(data=df, x="Condition", y="BPM", order=hue_order, hue='Condition', hue_order=hue_order,
  216. dodge=False, ax=axes[0])
  217. handles, labels = axes[0].get_legend_handles_labels()
  218. axes[0].legend(handles=handles, labels=['A (Anodal)', 'C (Cathodal)', 'B (Sham)'], loc='upper right')
  219. sns.boxplot(df, x='Condition', y='BDev', order=hue_order,
  220. ax=axes[1], boxprops={'alpha': 0.4}, showfliers=False)
  221. sns.stripplot(data=df, x="Condition", y="BDev", order=hue_order, hue='Condition', hue_order=hue_order,
  222. dodge=False, ax=axes[1], legend=False)
  223. handles, labels = axes[0].get_legend_handles_labels()
  224. plt.show()
  225. # create tables for the stats
  226. df = df.drop(['Session'], axis=1)
  227. wide_df = df.pivot(index='Subject', columns='Condition', values=['BPM', 'BDev', 'BPM_Q1',
  228. 'BPM_Q2', 'BPM_Q3', 'BPM_Q4',
  229. 'BDev_Q1', 'BDev_Q2', 'BDev_Q3', 'BDev_Q4'])
  230. wide_df.columns = ['_'.join(col).strip() for col in wide_df.columns.values]
  231. wide_df.reset_index('Subject', inplace=True)
  232. wide_df.to_csv(result_path + 'BPM_BDev_unblind.csv', sep=',', index=None)
  233. if within_sub_plot:
  234. df = pd.read_csv(result_path + 'BPM_BDev_unblind.csv', sep=',')
  235. # 1. Breathing rate BPM
  236. # cathodal comparison
  237. cathodal = df.drop(labels=['BPM_A', 'BDev_A', 'BDev_B', 'BDev_C',
  238. 'BPM_Q1_A', 'BPM_Q2_A', 'BPM_Q3_A', 'BPM_Q4_A',
  239. 'BDev_Q1_A', 'BDev_Q2_A', 'BDev_Q3_A', 'BDev_Q4_A'
  240. ], axis=1)
  241. cathodal.dropna(axis=0, inplace=True)
  242. cathodal.reset_index(inplace=True, drop=True)
  243. cathodal.drop('Subject', axis=1, inplace=True)
  244. sns.set_context("poster")
  245. sns.set_style("white")
  246. jitter = 0.05
  247. df_x_jitter = pd.DataFrame(np.random.normal(loc=0, scale=jitter, size=(cathodal.values.shape[0], 2)),
  248. columns=['Sham', 'Cathodal'])
  249. df_x_jitter += np.arange(2)
  250. fig, ax = plt.subplots(1, 2, figsize=(12, 8), sharey=True)
  251. fig.suptitle("Breathing rate", fontsize=30)
  252. b = sns.boxplot(ax=ax[0], x=np.repeat(0, len(cathodal)), y=cathodal['BPM_B'], color=color_blue, width=0.5,
  253. native_scale=True, showfliers=False)
  254. for patch in b.patches:
  255. r, g, b, a = patch.get_facecolor()
  256. patch.set_facecolor((r, g, b, 0.7))
  257. c = sns.boxplot(ax=ax[0], x=np.repeat(1, len(cathodal)), y=cathodal['BPM_C'], color=color_red, width=0.5,
  258. native_scale=True, showfliers=False)
  259. for patch in c.patches:
  260. r, g, b, a = patch.get_facecolor()
  261. patch.set_facecolor((r, g, b, 0.7))
  262. df_sham = pd.DataFrame({'jitter': df_x_jitter['Sham'], 'bpm': cathodal['BPM_B']})
  263. df_cath = pd.DataFrame({'jitter': df_x_jitter['Cathodal'], 'bpm': cathodal['BPM_C']})
  264. sns.scatterplot(ax=ax[0], data=df_sham, x='jitter', y='bpm', color=color_blue, zorder=100, edgecolor="black")
  265. sns.scatterplot(ax=ax[0], data=df_cath, x='jitter', y='bpm', color=color_red, zorder=100, edgecolor="black")
  266. ax[0].set_xticks(range(2))
  267. ax[0].set_xticklabels(['Sham', 'Cathodal'])
  268. ax[0].tick_params(axis='x', which='major', labelsize=25)
  269. ax[0].set_xlim(-1.0, 2)
  270. sns.despine()
  271. ax[0].set_xlabel('')
  272. ax[0].set_ylabel('Breaths per minute', fontsize=25)
  273. plt.subplots_adjust(bottom=0.2, left=0.15)
  274. ax[0].set_title('Cathodal', fontsize=25)
  275. for idx in cathodal.index:
  276. ax[0].plot(df_x_jitter.loc[idx, ['Sham', 'Cathodal']], cathodal.loc[idx, ['BPM_B', 'BPM_C']], color='grey',
  277. linewidth=0.5, linestyle='--', zorder=-1)
  278. # anodal comparison
  279. anodal = df.drop(labels=['BPM_C', 'BDev_A', 'BDev_B', 'BDev_C',
  280. 'BPM_Q1_C', 'BPM_Q2_C', 'BPM_Q3_C', 'BPM_Q4_C',
  281. 'BDev_Q1_C', 'BDev_Q2_C', 'BDev_Q3_C', 'BDev_Q4_C'
  282. ], axis=1)
  283. anodal.dropna(axis=0, inplace=True)
  284. anodal.reset_index(inplace=True, drop=True)
  285. anodal.drop('Subject', axis=1, inplace=True)
  286. df_x_jitter = pd.DataFrame(np.random.normal(loc=0, scale=jitter, size=(anodal.values.shape[0], 2)),
  287. columns=['Sham', 'Anodal'])
  288. df_x_jitter += np.arange(2)
  289. b = sns.boxplot(ax=ax[1], x=np.repeat(0, len(anodal)), y=anodal['BPM_B'], color=color_blue, width=0.5,
  290. native_scale=True, showfliers=False)
  291. for patch in b.patches:
  292. r, g, b, a = patch.get_facecolor()
  293. patch.set_facecolor((r, g, b, 0.7))
  294. c = sns.boxplot(ax=ax[1], x=np.repeat(1, len(anodal)), y=anodal['BPM_A'], color=color_orange, width=0.5,
  295. native_scale=True, showfliers=False)
  296. for patch in c.patches:
  297. r, g, b, a = patch.get_facecolor()
  298. patch.set_facecolor((r, g, b, 0.7))
  299. df_sham = pd.DataFrame({'jitter': df_x_jitter['Sham'], 'bpm': anodal['BPM_B']})
  300. df_anod = pd.DataFrame({'jitter': df_x_jitter['Anodal'], 'bpm': anodal['BPM_A']})
  301. sns.scatterplot(ax=ax[1], data=df_sham, x='jitter', y='bpm', color=color_blue, zorder=100, edgecolor="black")
  302. sns.scatterplot(ax=ax[1], data=df_anod, x='jitter', y='bpm', color=color_orange, zorder=100, edgecolor="black")
  303. ax[1].set_xticks(range(2))
  304. ax[1].set_xticklabels(['Sham', 'Anodal'])
  305. ax[1].tick_params(axis='x', which='major', labelsize=25)
  306. ax[1].set_xlim(-1.0, 2)
  307. sns.despine()
  308. ax[1].set_xlabel('')
  309. ax[1].set_ylabel('Breaths per minute', fontsize=25)
  310. plt.subplots_adjust(bottom=0.2, left=0.15)
  311. ax[1].set_title('Anodal', fontsize=25)
  312. for idx in anodal.index:
  313. ax[1].plot(df_x_jitter.loc[idx, ['Sham', 'Anodal']], anodal.loc[idx, ['BPM_B', 'BPM_A']], color='grey',
  314. linewidth=0.5, linestyle='--', zorder=-1)
  315. plt.savefig(result_path + 'BR_within_sub.png')
  316. plt.show()
  317. # 2. Breathing rate variability HRV
  318. # cathodal comparison
  319. cathodal = df.drop(labels=['BDev_A', 'BPM_A', 'BPM_B', 'BPM_C',
  320. 'BPM_Q1_A', 'BPM_Q2_A', 'BPM_Q3_A', 'BPM_Q4_A',
  321. 'BDev_Q1_A', 'BDev_Q2_A', 'BDev_Q3_A', 'BDev_Q4_A'
  322. ], axis=1)
  323. cathodal.dropna(axis=0, inplace=True)
  324. cathodal.reset_index(inplace=True, drop=True)
  325. cathodal.drop('Subject', axis=1, inplace=True)
  326. sns.set_context("poster")
  327. sns.set_style("white")
  328. jitter = 0.05
  329. df_x_jitter = pd.DataFrame(np.random.normal(loc=0, scale=jitter, size=(cathodal.values.shape[0], 2)),
  330. columns=['Sham', 'Cathodal'])
  331. df_x_jitter += np.arange(2)
  332. fig, ax = plt.subplots(1, 2, figsize=(12, 8), sharey=True)
  333. fig.suptitle("Breathing rate variability", fontsize=30)
  334. b = sns.boxplot(ax=ax[0], x=np.repeat(0, len(cathodal)), y=cathodal['BDev_B'], color=color_blue, width=0.5,
  335. native_scale=True, showfliers=False)
  336. for patch in b.patches:
  337. r, g, b, a = patch.get_facecolor()
  338. patch.set_facecolor((r, g, b, 0.7))
  339. c = sns.boxplot(ax=ax[0], x=np.repeat(1, len(cathodal)), y=cathodal['BDev_C'], color=color_red, width=0.5,
  340. native_scale=True, showfliers=False)
  341. for patch in c.patches:
  342. r, g, b, a = patch.get_facecolor()
  343. patch.set_facecolor((r, g, b, 0.7))
  344. df_sham = pd.DataFrame({'jitter': df_x_jitter['Sham'], 'bdev': cathodal['BDev_B']})
  345. df_cath = pd.DataFrame({'jitter': df_x_jitter['Cathodal'], 'bdev': cathodal['BDev_C']})
  346. sns.scatterplot(ax=ax[0], data=df_sham, x='jitter', y='bdev', color=color_blue, zorder=100, edgecolor="black")
  347. sns.scatterplot(ax=ax[0], data=df_cath, x='jitter', y='bdev', color=color_red, zorder=100, edgecolor="black")
  348. ax[0].set_xticks(range(2))
  349. ax[0].set_xticklabels(['Sham', 'Cathodal'])
  350. ax[0].tick_params(axis='x', which='major', labelsize=25)
  351. ax[0].set_xlim(-1.0, 2)
  352. sns.despine()
  353. ax[0].set_xlabel('')
  354. ax[0].set_ylabel('SD of breath intervals', fontsize=25)
  355. plt.subplots_adjust(bottom=0.2, left=0.15)
  356. ax[0].set_title('Cathodal', fontsize=25)
  357. for idx in cathodal.index:
  358. ax[0].plot(df_x_jitter.loc[idx, ['Sham', 'Cathodal']], cathodal.loc[idx, ['BDev_B', 'BDev_C']], color='grey',
  359. linewidth=0.5, linestyle='--', zorder=-1)
  360. # anodal comparison
  361. anodal = df.drop(labels=['BDev_C', 'BPM_A', 'BPM_B', 'BPM_C',
  362. 'BPM_Q1_C', 'BPM_Q2_C', 'BPM_Q3_C', 'BPM_Q4_C',
  363. 'BDev_Q1_C', 'BDev_Q2_C', 'BDev_Q3_C', 'BDev_Q4_C'
  364. ], axis=1)
  365. anodal.dropna(axis=0, inplace=True)
  366. anodal.reset_index(inplace=True, drop=True)
  367. anodal.drop('Subject', axis=1, inplace=True)
  368. df_x_jitter = pd.DataFrame(np.random.normal(loc=0, scale=jitter, size=(anodal.values.shape[0], 2)),
  369. columns=['Sham', 'Anodal'])
  370. df_x_jitter += np.arange(2)
  371. b = sns.boxplot(ax=ax[1], x=np.repeat(0, len(anodal)), y=anodal['BDev_B'], color=color_blue, width=0.5,
  372. native_scale=True, showfliers=False)
  373. for patch in b.patches:
  374. r, g, b, a = patch.get_facecolor()
  375. patch.set_facecolor((r, g, b, 0.7))
  376. c = sns.boxplot(ax=ax[1], x=np.repeat(1, len(anodal)), y=anodal['BDev_A'], color=color_orange, width=0.5,
  377. native_scale=True, showfliers=False)
  378. for patch in c.patches:
  379. r, g, b, a = patch.get_facecolor()
  380. patch.set_facecolor((r, g, b, 0.7))
  381. df_sham = pd.DataFrame({'jitter': df_x_jitter['Sham'], 'bdev': anodal['BDev_B']})
  382. df_anod = pd.DataFrame({'jitter': df_x_jitter['Anodal'], 'bdev': anodal['BDev_A']})
  383. sns.scatterplot(ax=ax[1], data=df_sham, x='jitter', y='bdev', color=color_blue, zorder=100, edgecolor="black")
  384. sns.scatterplot(ax=ax[1], data=df_anod, x='jitter', y='bdev', color=color_orange, zorder=100, edgecolor="black")
  385. ax[1].set_xticks(range(2))
  386. ax[1].set_xticklabels(['Sham', 'Anodal'])
  387. ax[1].tick_params(axis='x', which='major', labelsize=25)
  388. ax[1].set_xlim(-1.0, 2)
  389. sns.despine()
  390. ax[1].set_xlabel('')
  391. ax[1].set_ylabel('SD of breath intervals', fontsize=25)
  392. plt.subplots_adjust(bottom=0.2, left=0.15)
  393. ax[1].set_title('Anodal', fontsize=25)
  394. for idx in anodal.index:
  395. ax[1].plot(df_x_jitter.loc[idx, ['Sham', 'Anodal']], anodal.loc[idx, ['BDev_B', 'BDev_A']], color='grey',
  396. linewidth=0.5, linestyle='--', zorder=-1)
  397. plt.savefig(result_path + 'BRV_within_sub.png')
  398. plt.show()
  399. if interaction_plot:
  400. df = pd.read_csv(result_path + 'BPM_BDev_unblind.csv', sep=',')
  401. # breathing rate
  402. br = df[df.columns.drop(list(df.filter(regex='BDev_')))]
  403. br = br[br.columns.drop(['BPM_A', 'BPM_B', 'BPM_C'])]
  404. df_q_long = pd.wide_to_long(br, stubnames=['BPM_Q1', 'BPM_Q2', 'BPM_Q3', 'BPM_Q4'], i='Subject', j='condition',
  405. sep='_', suffix=r'\w+').reset_index()
  406. df_q_longer = pd.wide_to_long(df_q_long, stubnames=['BPM'], i=['Subject', 'condition'], j='Quartile',
  407. sep='_Q', suffix=r'\w+').reset_index()
  408. sns.set_context("poster")
  409. sns.set_style("white")
  410. fig, ax = plt.subplots(1, 1, figsize=(12, 8))
  411. fig.suptitle("Breathing rate over time", fontsize=30)
  412. sns.lineplot(data=df_q_longer, x='Quartile', y='BPM', hue='condition', palette=[color_blue, color_red, color_orange],
  413. hue_order=['B', 'C', 'A'], errorbar='se')
  414. handles, labels = ax.get_legend_handles_labels()
  415. ax.xaxis.get_major_locator().set_params(integer=True)
  416. plt.ylim(14, 19)
  417. sns.despine()
  418. plt.subplots_adjust(bottom=0.2, left=0.15)
  419. ax.set_ylabel('Quartile', fontsize=25)
  420. ax.set_ylabel('Breaths per minute', fontsize=25)
  421. plt.legend(handles=handles, labels=['Sham', 'Cathodal', 'Anodal'])
  422. plt.savefig(result_path + 'BR_Quartile_interaction.png')
  423. plt.show()

UE_analysis_4_respiration.py at commit 3cbcf57, no license · at the source

Overview

Authors: Hongyan Zhao1, Ulrike Horn1, Melanie Freund1, Anna Bujanow2, Christopher Gundlach3, Gesa Hartwigsen4,5, Falk Eippert1
  1. Max Planck Research Group Pain Perception, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Germany
  2. Methods and Development Group Nuclear Magnetic Resonance, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Germany
  3. Experimental Psychology and Methods, Wilhelm Wundt Institute for Psychology, Leipzig University, Leipzig, Germany
  4. Cognitive and Biological Psychology, Wilhelm Wundt Institute for Psychology, Leipzig University, Leipzig, Germany
  5. Lise Meitner Research Group Cognition and Plasticity, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Germany
Journal: Imaging neuroscience (Cambridge, Mass.), volume 4, article IMAG.a.1292
Dates: received 2 February 2024; accepted 15 June 2026; published online 14 July 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1162/imag.a.1292 · PMID 42459499 · PMCID PMC13370751 · OpenAlex W4389752166
Open access: diamond, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: behavior only (modality), human (organism)
Methods: Spectral & time-frequency, Statistics, Physiology & signal measures, Smoothing, state filtering, decompositions
Keywords: spinal cord, transcutaneous spinal direct current stimulation, adverse effects, unspecific effects, structured questionnaire, autonomic nervous system
Topic: Transcranial Magnetic Stimulation Studies (Neurology, Neuroscience), according to OpenAlex
Funding: European Research Council (758974)
Citations: not cited yet (Europe PMC); 83 references in the paper

Abstract

Transcutaneous spinal direct current stimulation (tsDCS) is a relatively recent method for non-invasively modulating neural activity in the spinal cord. Despite its growing prominence, comprehensive studies addressing its potential adverse effects (AEs) and unspecific effects (UEs) are lacking. In this study, we conducted a systematic investigation of the potential AEs and UEs of tsDCS in healthy volunteers (N=20) who underwent a double-blind within-participant design, employing anodal, cathodal, and sham tsDCS of the thoracolumbar spinal cord. Our approach involved utilizing a newly developed structured questionnaire (to assess subjectively reported AEs) in combination with tsDCS-concurrent recording of skin conductance, cardiac and respiratory activity (to assess UEs in bodily state). The most frequent participant-reported AEs were sensations of burning, tingling, and itching, although they were largely described as mild; skin redness (experimenter-reported) occurred even more frequently. Importantly, when comparing AEs between active and sham tsDCS via frequentist and Bayesian analysis approaches, the results were largely in favour of no difference between conditions (with the exception of skin redness). A similar picture emerged for most UE metrics, suggesting that tsDCS does not induce changes in bodily state, at least as measured by our autonomic nervous system metrics. We believe that the strategy employed here could serve as a starting point for a systematic AE and UE assessment in clinical populations, longitudinal designs, and when targeting different spinal sites. Taken together, our results contribute to assessing the tolerability and specificity of tsDCS, in order to further the application of this spinal neuromodulation method in health and disease.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 5 matches between paragraphs and lines of code.

eippertlab/tsdcs-sideeffects

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 3cbcf57529a400c7cc0b462dd7ebc68b289c2dc2, 25 June 2026
Languages: Python (7), MATLAB (3)
Size: 11 files, 10 scripts
Software Heritage: archived
Found in: “Data and Code Availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Matplotlib (7 files), NumPy (7 files), pandas (6 files), seaborn (5 files), MNE-Python (4 files), SciPy (4 files)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
11 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 10 scripts, each with its path and the digest of its content;
  • 5 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Data and Code Availability

The underlying data are openly available (https://osf.io/f7spw/), as is all analysis code (https://github.com/eippertlab/tsdcs-sideeffects).

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 7 authors, 6 keywords, 1 funder, 81 references.

Cite

This paper

Zhao, H., Horn, U., Freund, M., Bujanow, A., Gundlach, C., Hartwigsen, G., & Eippert, F. (2026). Assessing adverse effects and unspecific effects of transcutaneous spinal direct current stimulation (tsDCS). Imaging neuroscience (Cambridge, Mass.), 4, IMAG.a.1292. https://doi.org/10.1162/imag.a.1292

BibTeX

@article{zhao2026assessing,
author = {Zhao, Hongyan and Horn, Ulrike and Freund, Melanie and Bujanow, Anna and Gundlach, Christopher and Hartwigsen, Gesa and Eippert, Falk},
title = {{Assessing adverse effects and unspecific effects of transcutaneous spinal direct current stimulation (tsDCS)}},
journal = {Imaging neuroscience (Cambridge, Mass.)},
year = {2026},
month = jul,
volume = {4},
pages = {IMAG.a.1292},
publisher = {MIT Press},
issn = {2837-6056},
doi = {10.1162/imag.a.1292},
url = {https://doi.org/10.1162/imag.a.1292},
pmid = {42459499},
pmcid = {PMC13370751}
}

RIS

TY - JOUR
AU - Zhao, Hongyan
AU - Horn, Ulrike
AU - Freund, Melanie
AU - Bujanow, Anna
AU - Gundlach, Christopher
AU - Hartwigsen, Gesa
AU - Eippert, Falk
TI - Assessing adverse effects and unspecific effects of transcutaneous spinal direct current stimulation (tsDCS)
T2 - Imaging neuroscience (Cambridge, Mass.)
J2 - Imaging Neurosci (Camb)
PY - 2026
DA - 2026/07/14
VL - 4
SP - IMAG.a.1292
SN - 2837-6056
PB - MIT Press
DO - 10.1162/imag.a.1292
UR - https://doi.org/10.1162/imag.a.1292
LA - en
ER -

CSL-JSON

{
"id": "10.1162/imag.a.1292",
"type": "article-journal",
"title": "Assessing adverse effects and unspecific effects of transcutaneous spinal direct current stimulation (tsDCS)",
"container-title": "Imaging neuroscience (Cambridge, Mass.)",
"author": [
{
"family": "Zhao",
"given": "Hongyan"
},
{
"family": "Horn",
"given": "Ulrike"
},
{
"family": "Freund",
"given": "Melanie"
},
{
"family": "Bujanow",
"given": "Anna"
},
{
"family": "Gundlach",
"given": "Christopher"
},
{
"family": "Hartwigsen",
"given": "Gesa"
},
{
"family": "Eippert",
"given": "Falk"
}
],
"container-title-short": "Imaging Neurosci (Camb)",
"volume": "4",
"page": "IMAG.a.1292",
"DOI": "10.1162/imag.a.1292",
"PMID": "42459499",
"PMCID": "PMC13370751",
"ISSN": "2837-6056",
"publisher": "MIT Press",
"URL": "https://doi.org/10.1162/imag.a.1292",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
14
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1371/journal.pone.0267718
Transcutaneous spinal direct current stimulation (tsDCS) does not affect postural sway of young and healthy subjects during quiet upright standing.
Journal: PloS one
In common: 24 references
[2] doi:10.1371/journal.pbio.3002828 [code]
A multichannel electrophysiological approach to noninvasively and precisely record human spinal cord activity.
Journal: PLoS biology
In common: MNE-Python, seaborn, pandas, 3 other tools, 1 reference, 2 authors
[3] doi:10.1162/imag_a_00273 [code]
Reliability of task-based fMRI in the dorsal horn of the human spinal cord.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: seaborn, pandas, SciPy, 2 other tools, 2 authors
[4] doi:10.1111/ejn.70375 [code]
Increase in Ia Afferent Synaptic Excitation of SOD1 G93A Mouse Motoneurons by 2-Week Anodal Trans-Spinal Direct Current Stimulation Does Not Ameliorate the Cellular Burden of the Disease.
Journal: The European journal of neuroscience
In common: 7 references
[5] doi:10.1016/j.neuroimage.2023.120152 [code]
Reliability of resting-state functional connectivity in the human spinal cord: Assessing the impact of distinct noise sources.
Journal: NeuroImage
In common: 1 reference, 2 authors
[6] doi:10.1002/hbm.26018 [code]
Automated slice-specific z-shimming for functional magnetic resonance imaging of the human spinal cord.
Journal: Human brain mapping
In common: 1 reference, 2 authors
[7] doi:10.1162/imag.a.938 [code]
Evaluating cardiac noise correction approaches for non-invasive electrophysiology of the human spinal cord.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: MNE-Python, seaborn, pandas, 3 other tools, 1 reference, author Falk Eippert
[8] doi:10.1093/braincomms/fcae129 [code]
Bayesian modelling disentangles language versus executive control disruption in stroke.
Journal: Brain communications
In common: seaborn, pandas, SciPy, 2 other tools, behavior only, author Gesa Hartwigsen
[9] doi:10.1523/jneurosci.0657-25.2025 [code]
Attentional Engagement with Target and Distractor Streams Predicts Speech Comprehension in Multitalker Environments.
Journal: The Journal of neuroscience : the official journal of the Society for Neuroscience
In common: MNE-Python, pandas, SciPy, 2 other tools, author Gesa Hartwigsen
[10] doi:10.1162/imag_a_00559 [code]
Body size and intracranial volume interact with the structure of the central nervous system: A multi-center in vivo neuroimaging study.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: seaborn, pandas, SciPy, 2 other tools, author Falk Eippert

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.1162/imag.a.1292.svg)](https://openscicode.org/badge/doi/10.1162/imag.a.1292)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1162/imag.a.1292.svg
   :target: https://openscicode.org/badge/doi/10.1162/imag.a.1292
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1162/imag.a.1292"><img src="https://openscicode.org/badge/doi/10.1162/imag.a.1292.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.