py-neuromodulation 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. py_neuromodulation/ConnectivityDecoding/Automated Anatomical Labeling 3 (Rolls 2020).nii +0 -0
  2. py_neuromodulation/ConnectivityDecoding/_get_grid_hull.m +34 -0
  3. py_neuromodulation/ConnectivityDecoding/_get_grid_whole_brain.py +106 -0
  4. py_neuromodulation/ConnectivityDecoding/_helper_write_connectome.py +119 -0
  5. py_neuromodulation/ConnectivityDecoding/mni_coords_cortical_surface.mat +0 -0
  6. py_neuromodulation/ConnectivityDecoding/mni_coords_whole_brain.mat +0 -0
  7. py_neuromodulation/ConnectivityDecoding/rmap_func_all.nii +0 -0
  8. py_neuromodulation/ConnectivityDecoding/rmap_struc.nii +0 -0
  9. py_neuromodulation/data/README +6 -0
  10. py_neuromodulation/data/dataset_description.json +8 -0
  11. py_neuromodulation/data/participants.json +32 -0
  12. py_neuromodulation/data/participants.tsv +2 -0
  13. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_space-mni_coordsystem.json +5 -0
  14. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_space-mni_electrodes.tsv +11 -0
  15. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_channels.tsv +11 -0
  16. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.eeg +0 -0
  17. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.json +18 -0
  18. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vhdr +35 -0
  19. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vmrk +13 -0
  20. py_neuromodulation/data/sub-testsub/ses-EphysMedOff/sub-testsub_ses-EphysMedOff_scans.tsv +2 -0
  21. py_neuromodulation/grid_cortex.tsv +40 -0
  22. py_neuromodulation/grid_subcortex.tsv +1429 -0
  23. py_neuromodulation/nm_settings.json +338 -0
  24. py_neuromodulation/nm_stream_offline.py +7 -6
  25. py_neuromodulation/plots/STN_surf.mat +0 -0
  26. py_neuromodulation/plots/Vertices.mat +0 -0
  27. py_neuromodulation/plots/faces.mat +0 -0
  28. py_neuromodulation/plots/grid.mat +0 -0
  29. {py_neuromodulation-0.0.3.dist-info → py_neuromodulation-0.0.4.dist-info}/METADATA +182 -182
  30. py_neuromodulation-0.0.4.dist-info/RECORD +72 -0
  31. {py_neuromodulation-0.0.3.dist-info → py_neuromodulation-0.0.4.dist-info}/WHEEL +1 -2
  32. docs/build/_downloads/09df217f95985497f45d69e2d4bdc5b1/plot_2_example_add_feature.py +0 -68
  33. docs/build/_downloads/3b4900a2b2818ff30362215b76f7d5eb/plot_1_example_BIDS.py +0 -233
  34. docs/build/_downloads/7e92dd2e6cc86b239d14cafad972ae4f/plot_3_example_sharpwave_analysis.py +0 -219
  35. docs/build/_downloads/c2db0bf2b334d541b00662b991682256/plot_6_real_time_demo.py +0 -97
  36. docs/build/_downloads/ce3914826f782cbd1ea8fd024eaf0ac3/plot_5_example_rmap_computing.py +0 -64
  37. docs/build/_downloads/da36848a41e6a3235d91fb7cfb6d59b4/plot_0_first_demo.py +0 -192
  38. docs/build/_downloads/eaa4305c75b19a1e2eea941f742a6331/plot_4_example_gridPointProjection.py +0 -210
  39. docs/build/html/_downloads/09df217f95985497f45d69e2d4bdc5b1/plot_2_example_add_feature.py +0 -68
  40. docs/build/html/_downloads/3b4900a2b2818ff30362215b76f7d5eb/plot_1_example_BIDS.py +0 -239
  41. docs/build/html/_downloads/7e92dd2e6cc86b239d14cafad972ae4f/plot_3_example_sharpwave_analysis.py +0 -219
  42. docs/build/html/_downloads/c2db0bf2b334d541b00662b991682256/plot_6_real_time_demo.py +0 -97
  43. docs/build/html/_downloads/ce3914826f782cbd1ea8fd024eaf0ac3/plot_5_example_rmap_computing.py +0 -64
  44. docs/build/html/_downloads/da36848a41e6a3235d91fb7cfb6d59b4/plot_0_first_demo.py +0 -192
  45. docs/build/html/_downloads/eaa4305c75b19a1e2eea941f742a6331/plot_4_example_gridPointProjection.py +0 -210
  46. docs/source/_build/html/_downloads/09df217f95985497f45d69e2d4bdc5b1/plot_2_example_add_feature.py +0 -76
  47. docs/source/_build/html/_downloads/0d0d0a76e8f648d5d3cbc47da6351932/plot_real_time_demo.py +0 -97
  48. docs/source/_build/html/_downloads/3b4900a2b2818ff30362215b76f7d5eb/plot_1_example_BIDS.py +0 -240
  49. docs/source/_build/html/_downloads/5d73cadc59a8805c47e3b84063afc157/plot_example_BIDS.py +0 -233
  50. docs/source/_build/html/_downloads/7660317fa5a6bfbd12fcca9961457fc4/plot_example_rmap_computing.py +0 -63
  51. docs/source/_build/html/_downloads/7e92dd2e6cc86b239d14cafad972ae4f/plot_3_example_sharpwave_analysis.py +0 -219
  52. docs/source/_build/html/_downloads/839e5b319379f7fd9e867deb00fd797f/plot_example_gridPointProjection.py +0 -210
  53. docs/source/_build/html/_downloads/ae8be19afe5e559f011fc9b138968ba0/plot_first_demo.py +0 -192
  54. docs/source/_build/html/_downloads/b8b06cacc17969d3725a0b6f1d7741c5/plot_example_sharpwave_analysis.py +0 -219
  55. docs/source/_build/html/_downloads/c2db0bf2b334d541b00662b991682256/plot_6_real_time_demo.py +0 -121
  56. docs/source/_build/html/_downloads/c31a86c0b68cb4167d968091ace8080d/plot_example_add_feature.py +0 -68
  57. docs/source/_build/html/_downloads/ce3914826f782cbd1ea8fd024eaf0ac3/plot_5_example_rmap_computing.py +0 -64
  58. docs/source/_build/html/_downloads/da36848a41e6a3235d91fb7cfb6d59b4/plot_0_first_demo.py +0 -189
  59. docs/source/_build/html/_downloads/eaa4305c75b19a1e2eea941f742a6331/plot_4_example_gridPointProjection.py +0 -210
  60. docs/source/auto_examples/plot_0_first_demo.py +0 -189
  61. docs/source/auto_examples/plot_1_example_BIDS.py +0 -240
  62. docs/source/auto_examples/plot_2_example_add_feature.py +0 -76
  63. docs/source/auto_examples/plot_3_example_sharpwave_analysis.py +0 -219
  64. docs/source/auto_examples/plot_4_example_gridPointProjection.py +0 -210
  65. docs/source/auto_examples/plot_5_example_rmap_computing.py +0 -64
  66. docs/source/auto_examples/plot_6_real_time_demo.py +0 -121
  67. docs/source/conf.py +0 -105
  68. examples/plot_0_first_demo.py +0 -189
  69. examples/plot_1_example_BIDS.py +0 -240
  70. examples/plot_2_example_add_feature.py +0 -76
  71. examples/plot_3_example_sharpwave_analysis.py +0 -219
  72. examples/plot_4_example_gridPointProjection.py +0 -210
  73. examples/plot_5_example_rmap_computing.py +0 -64
  74. examples/plot_6_real_time_demo.py +0 -121
  75. packages/realtime_decoding/build/lib/realtime_decoding/__init__.py +0 -4
  76. packages/realtime_decoding/build/lib/realtime_decoding/decoder.py +0 -104
  77. packages/realtime_decoding/build/lib/realtime_decoding/features.py +0 -163
  78. packages/realtime_decoding/build/lib/realtime_decoding/helpers.py +0 -15
  79. packages/realtime_decoding/build/lib/realtime_decoding/run_decoding.py +0 -345
  80. packages/realtime_decoding/build/lib/realtime_decoding/trainer.py +0 -54
  81. packages/tmsi/build/lib/TMSiFileFormats/__init__.py +0 -37
  82. packages/tmsi/build/lib/TMSiFileFormats/file_formats/__init__.py +0 -36
  83. packages/tmsi/build/lib/TMSiFileFormats/file_formats/lsl_stream_writer.py +0 -200
  84. packages/tmsi/build/lib/TMSiFileFormats/file_formats/poly5_file_writer.py +0 -496
  85. packages/tmsi/build/lib/TMSiFileFormats/file_formats/poly5_to_edf_converter.py +0 -236
  86. packages/tmsi/build/lib/TMSiFileFormats/file_formats/xdf_file_writer.py +0 -977
  87. packages/tmsi/build/lib/TMSiFileFormats/file_readers/__init__.py +0 -35
  88. packages/tmsi/build/lib/TMSiFileFormats/file_readers/edf_reader.py +0 -116
  89. packages/tmsi/build/lib/TMSiFileFormats/file_readers/poly5reader.py +0 -294
  90. packages/tmsi/build/lib/TMSiFileFormats/file_readers/xdf_reader.py +0 -229
  91. packages/tmsi/build/lib/TMSiFileFormats/file_writer.py +0 -102
  92. packages/tmsi/build/lib/TMSiPlotters/__init__.py +0 -2
  93. packages/tmsi/build/lib/TMSiPlotters/gui/__init__.py +0 -39
  94. packages/tmsi/build/lib/TMSiPlotters/gui/_plotter_gui.py +0 -234
  95. packages/tmsi/build/lib/TMSiPlotters/gui/plotting_gui.py +0 -440
  96. packages/tmsi/build/lib/TMSiPlotters/plotters/__init__.py +0 -44
  97. packages/tmsi/build/lib/TMSiPlotters/plotters/hd_emg_plotter.py +0 -446
  98. packages/tmsi/build/lib/TMSiPlotters/plotters/impedance_plotter.py +0 -589
  99. packages/tmsi/build/lib/TMSiPlotters/plotters/signal_plotter.py +0 -1326
  100. packages/tmsi/build/lib/TMSiSDK/__init__.py +0 -54
  101. packages/tmsi/build/lib/TMSiSDK/device.py +0 -588
  102. packages/tmsi/build/lib/TMSiSDK/devices/__init__.py +0 -34
  103. packages/tmsi/build/lib/TMSiSDK/devices/saga/TMSi_Device_API.py +0 -1764
  104. packages/tmsi/build/lib/TMSiSDK/devices/saga/__init__.py +0 -34
  105. packages/tmsi/build/lib/TMSiSDK/devices/saga/saga_device.py +0 -1366
  106. packages/tmsi/build/lib/TMSiSDK/devices/saga/saga_types.py +0 -520
  107. packages/tmsi/build/lib/TMSiSDK/devices/saga/xml_saga_config.py +0 -165
  108. packages/tmsi/build/lib/TMSiSDK/error.py +0 -95
  109. packages/tmsi/build/lib/TMSiSDK/sample_data.py +0 -63
  110. packages/tmsi/build/lib/TMSiSDK/sample_data_server.py +0 -99
  111. packages/tmsi/build/lib/TMSiSDK/settings.py +0 -45
  112. packages/tmsi/build/lib/TMSiSDK/tmsi_device.py +0 -111
  113. packages/tmsi/build/lib/__init__.py +0 -4
  114. packages/tmsi/build/lib/apex_sdk/__init__.py +0 -34
  115. packages/tmsi/build/lib/apex_sdk/device/__init__.py +0 -41
  116. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_API.py +0 -1009
  117. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_API_enums.py +0 -239
  118. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_API_structures.py +0 -668
  119. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_device.py +0 -1611
  120. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_dongle.py +0 -38
  121. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_event_reader.py +0 -57
  122. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_channel.py +0 -44
  123. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_config.py +0 -150
  124. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_const.py +0 -36
  125. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_impedance_channel.py +0 -48
  126. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_info.py +0 -108
  127. packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/dongle_info.py +0 -39
  128. packages/tmsi/build/lib/apex_sdk/device/devices/apex/measurements/download_measurement.py +0 -77
  129. packages/tmsi/build/lib/apex_sdk/device/devices/apex/measurements/eeg_measurement.py +0 -150
  130. packages/tmsi/build/lib/apex_sdk/device/devices/apex/measurements/impedance_measurement.py +0 -129
  131. packages/tmsi/build/lib/apex_sdk/device/threads/conversion_thread.py +0 -59
  132. packages/tmsi/build/lib/apex_sdk/device/threads/sampling_thread.py +0 -57
  133. packages/tmsi/build/lib/apex_sdk/device/tmsi_channel.py +0 -83
  134. packages/tmsi/build/lib/apex_sdk/device/tmsi_device.py +0 -201
  135. packages/tmsi/build/lib/apex_sdk/device/tmsi_device_enums.py +0 -103
  136. packages/tmsi/build/lib/apex_sdk/device/tmsi_dongle.py +0 -43
  137. packages/tmsi/build/lib/apex_sdk/device/tmsi_event_reader.py +0 -50
  138. packages/tmsi/build/lib/apex_sdk/device/tmsi_measurement.py +0 -118
  139. packages/tmsi/build/lib/apex_sdk/sample_data_server/__init__.py +0 -33
  140. packages/tmsi/build/lib/apex_sdk/sample_data_server/event_data.py +0 -44
  141. packages/tmsi/build/lib/apex_sdk/sample_data_server/sample_data.py +0 -50
  142. packages/tmsi/build/lib/apex_sdk/sample_data_server/sample_data_server.py +0 -136
  143. packages/tmsi/build/lib/apex_sdk/tmsi_errors/error.py +0 -126
  144. packages/tmsi/build/lib/apex_sdk/tmsi_sdk.py +0 -113
  145. packages/tmsi/build/lib/apex_sdk/tmsi_utilities/apex/apex_structure_generator.py +0 -134
  146. packages/tmsi/build/lib/apex_sdk/tmsi_utilities/decorators.py +0 -60
  147. packages/tmsi/build/lib/apex_sdk/tmsi_utilities/logger_filter.py +0 -42
  148. packages/tmsi/build/lib/apex_sdk/tmsi_utilities/singleton.py +0 -42
  149. packages/tmsi/build/lib/apex_sdk/tmsi_utilities/support_functions.py +0 -72
  150. packages/tmsi/build/lib/apex_sdk/tmsi_utilities/tmsi_logger.py +0 -98
  151. py_neuromodulation-0.0.3.dist-info/RECORD +0 -188
  152. py_neuromodulation-0.0.3.dist-info/top_level.txt +0 -5
  153. tests/__init__.py +0 -0
  154. tests/conftest.py +0 -117
  155. tests/test_all_examples.py +0 -10
  156. tests/test_all_features.py +0 -63
  157. tests/test_bispectra.py +0 -70
  158. tests/test_bursts.py +0 -105
  159. tests/test_feature_sampling_rates.py +0 -143
  160. tests/test_fooof.py +0 -16
  161. tests/test_initalization_offline_stream.py +0 -41
  162. tests/test_multiprocessing.py +0 -58
  163. tests/test_nan_values.py +0 -29
  164. tests/test_nm_filter.py +0 -95
  165. tests/test_nm_resample.py +0 -63
  166. tests/test_normalization_settings.py +0 -146
  167. tests/test_notch_filter.py +0 -31
  168. tests/test_osc_features.py +0 -424
  169. tests/test_preprocessing_filter.py +0 -151
  170. tests/test_rereference.py +0 -171
  171. tests/test_sampling.py +0 -57
  172. tests/test_settings_change_after_init.py +0 -76
  173. tests/test_sharpwave.py +0 -165
  174. tests/test_target_channel_add.py +0 -100
  175. tests/test_timing.py +0 -80
  176. {py_neuromodulation-0.0.3.dist-info → py_neuromodulation-0.0.4.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,34 @@
1
+ addpath('C:\code\wjn_toolbox');
2
+ addpath(genpath('C:\code\leaddbs'));
3
+ addpath(genpath('C:\code\spm12'));
4
+
5
+
6
+ %%
7
+ ctx = wjn_mni_cortex();
8
+ downsample_ctx=ctx.vertices(1:20:end,:); %downsample by 10
9
+
10
+ save("downsampled_cortex.mat", "downsample_ctx")
11
+
12
+ figure;
13
+ scatter3(downsample_ctx(:,1), downsample_ctx(:,2), downsample_ctx(:,3), 'filled');
14
+ title('3D Scatter Plot Example');
15
+ xlabel('X-axis');
16
+ ylabel('Y-axis');
17
+ zlabel('Z-axis');
18
+ grid on;
19
+
20
+
21
+
22
+ PATH_OUT = "D:\Connectome_RMAP_OUT\ROIs";
23
+
24
+ for a =1:size(downsample_ctx,1)
25
+ disp(a)
26
+ roiname = fullfile(PATH_OUT, strcat('ROI-', string(a), '.nii'));
27
+ mni = [downsample_ctx(a, 1) downsample_ctx(a, 2) downsample_ctx(a, 3)];
28
+ wjn_spherical_roi(roiname,mni,4);
29
+ end
30
+
31
+
32
+
33
+
34
+
@@ -0,0 +1,106 @@
1
+ import nibabel as nib
2
+ import numpy as np
3
+ import scipy.io as sio
4
+ import os
5
+ from matplotlib import pyplot as plt
6
+
7
+
8
+ class NiiToMNI:
9
+
10
+ def __init__(
11
+ self,
12
+ PATH_nii_file: str = r"C:\code\RMap_ROI_Estimation\Automated Anatomical Labeling 3 (Rolls 2020).nii",
13
+ ) -> None:
14
+
15
+ self.img = nib.load(PATH_nii_file)
16
+ self.data = self.img.get_fdata()
17
+
18
+ def downsample_nii(
19
+ self,
20
+ resampling_factor: int = 150,
21
+ ):
22
+
23
+ # PATH_MNI_TO_ATLAS = r"C:\code\mni_to_atlas\src\mni_to_atlas\atlases\AAL.nii"
24
+ # img_mni_to_atlas = nib.load(PATH_MNI_TO_ATLAS)
25
+
26
+ x_dim, y_dim, z_dim = self.data.shape
27
+
28
+ # Create arrays of voxel coordinates
29
+ x_coords, y_coords, z_coords = np.meshgrid(
30
+ range(x_dim), range(y_dim), range(z_dim), indexing="ij"
31
+ )
32
+
33
+ # Downsample here the voxels --> check lateron if the voxels have non-zero values
34
+ x_c_flatten = x_coords.flatten()[::resampling_factor]
35
+ y_c_flatten = y_coords.flatten()[::resampling_factor]
36
+ z_c_flatten = z_coords.flatten()[::resampling_factor]
37
+
38
+ # Combine coordinates into a single array
39
+ voxel_coordinates = np.column_stack(
40
+ (
41
+ x_c_flatten,
42
+ y_c_flatten,
43
+ z_c_flatten,
44
+ np.ones(x_c_flatten.shape[0]),
45
+ )
46
+ )
47
+
48
+ aff_m = self.img.affine
49
+ aff_m[0, 0] = 2
50
+ aff_m[0, 3] = -90
51
+
52
+ mni_coordinates = np.dot(aff_m, voxel_coordinates.T).T[:, :3]
53
+
54
+ return mni_coordinates
55
+
56
+ def select_non_zero_voxels(
57
+ self,
58
+ mni_coordinates: np.array,
59
+ ):
60
+
61
+ coords = np.hstack(
62
+ (mni_coordinates, np.ones((mni_coordinates.shape[0], 1)))
63
+ )
64
+
65
+ # and transform back to get the voxel values
66
+ voxels_downsampled = np.array(
67
+ np.linalg.solve(self.img.affine, coords.T).T
68
+ ).astype(int)[:, :3]
69
+
70
+ ival = []
71
+ coord_ = []
72
+ for i in range(voxels_downsampled.shape[0]):
73
+ ival.append(self.data[tuple(voxels_downsampled[i, :])])
74
+ coord_.append(mni_coordinates[i, :])
75
+
76
+ # get only voxel values non-zero
77
+ ival = np.array(ival)
78
+ coord_ = np.array(coord_)
79
+ ival_non_zero = ival[ival != 0]
80
+ coord_non_zero = coord_[ival != 0]
81
+ print(coord_non_zero.shape)
82
+
83
+ return coord_non_zero, ival_non_zero
84
+
85
+ def plot_3d_coordinates(self, coord_non_zero: np.array):
86
+ fig = plt.figure()
87
+ ax = fig.add_subplot(111, projection="3d")
88
+ ax.scatter(
89
+ coord_non_zero[:, 0],
90
+ coord_non_zero[:, 1],
91
+ coord_non_zero[:, 2],
92
+ s=50,
93
+ alpha=0.2,
94
+ )
95
+ plt.show()
96
+
97
+
98
+ if __name__ == "__main__":
99
+
100
+ nii_to_mni = NiiToMNI(
101
+ PATH_nii_file=r"C:\code\py_neuromodulation\ConnectivityDecoding\Automated Anatomical Labeling 3 (Rolls 2020).nii"
102
+ )
103
+ mni_coordinates = nii_to_mni.downsample_nii(resampling_factor=150)
104
+ coord_non_zero, ival_non_zero = nii_to_mni.select_non_zero_voxels(
105
+ mni_coordinates
106
+ )
@@ -0,0 +1,119 @@
1
+ import nibabel as nib
2
+ import numpy as np
3
+ import scipy.io as sio
4
+ import os
5
+ from matplotlib import pyplot as plt
6
+
7
+
8
+ def write_connectome_mat(
9
+ PATH_Fingerprints: str = r"D:\Connectome_RMAP_OUT\ROIs\HCP1000 6K",
10
+ PATH_CONNECTOME: str = os.path.join(
11
+ "py_neuromodulation",
12
+ "ConnectivityDecoding",
13
+ "connectome_struct.mat",
14
+ ),
15
+ func_: bool = False,
16
+ ):
17
+
18
+ # connectome = sio.loadmat(PATH_CONNECTOME) # check if read was successful
19
+
20
+ # load all fingerprints and put them in .npy
21
+ dict_connectome = {}
22
+ if func_ is False:
23
+ files_fps = [f for f in os.listdir(PATH_Fingerprints) if ".nii" in f]
24
+ else:
25
+ files_fps = [
26
+ f
27
+ for f in os.listdir(PATH_Fingerprints)
28
+ if "func_seed_AvgR_Fz.nii" in f
29
+ ]
30
+
31
+ # I except 1025 files, check which ones are missing
32
+ missing_files = []
33
+
34
+ for i in range(1, 1026):
35
+
36
+ MISSING = False
37
+
38
+ if func_ is False:
39
+ if f"ROI-{i}_struc_seed.nii" not in files_fps:
40
+ missing_files.append(f"ROI-{i}_struc_seed.nii")
41
+ MISSING = True
42
+ else:
43
+ if f"ROI-{i}_func_seed_AvgR_Fz.nii" not in files_fps:
44
+ missing_files.append(f"ROI-{i}_func_seed_AvgR_Fz.nii")
45
+ MISSING = True
46
+
47
+ if MISSING:
48
+ ROI_file = os.path.join(
49
+ r"D:\Connectome_RMAP_OUT\whole_brain\ROIs", f"ROI-{i}.nii"
50
+ )
51
+ # copy the ROI file to the following folder:
52
+ PATH_ROI_OUT = (
53
+ r"D:\Connectome_RMAP_OUT\whole_brain\ROI_missing_struc"
54
+ )
55
+ import shutil
56
+
57
+ shutil.copy(ROI_file, os.path.join(PATH_ROI_OUT, f"ROI-{i}.nii"))
58
+
59
+ for idx, f in enumerate(files_fps):
60
+ # load the .nii file and put it all in in a dictionary with the name of the file
61
+ fp = (
62
+ nib.load(os.path.join(PATH_Fingerprints, f))
63
+ .get_fdata()
64
+ .astype(np.float16)
65
+ )
66
+ if "struc" in f:
67
+ dict_connectome[f[f.find("ROI-") + 4 : f.find("_struc")]] = fp
68
+ else:
69
+ dict_connectome[
70
+ f[f.find("ROI-") + 4 : f.find("_func_seed_AvgR_Fz.nii")]
71
+ ] = fp
72
+
73
+ print(idx)
74
+ # save the dictionary
75
+ sio.savemat(
76
+ PATH_CONNECTOME,
77
+ dict_connectome,
78
+ )
79
+
80
+
81
+ if __name__ == "__main__":
82
+
83
+ write_connectome_mat(
84
+ PATH_Fingerprints=r"D:\Connectome_RMAP_OUT\whole_brain\struc\HCP1000 6K",
85
+ PATH_CONNECTOME=os.path.join(
86
+ "py_neuromodulation",
87
+ "ConnectivityDecoding",
88
+ "connectome_whole_brain_struc.mat",
89
+ ),
90
+ ) # 58 files are missing
91
+
92
+ write_connectome_mat(
93
+ PATH_Fingerprints=r"D:\Connectome_RMAP_OUT\whole_brain\func",
94
+ PATH_CONNECTOME=os.path.join(
95
+ "py_neuromodulation",
96
+ "ConnectivityDecoding",
97
+ "connectome_whole_brain_func.mat",
98
+ ),
99
+ func_=True,
100
+ )
101
+
102
+ write_connectome_mat(
103
+ PATH_Fingerprints=r"D:\Connectome_RMAP_OUT\hull\func\GSP 1000 (Yeo 2011)_Full Set (Yeo 2011)",
104
+ PATH_CONNECTOME=os.path.join(
105
+ "py_neuromodulation",
106
+ "ConnectivityDecoding",
107
+ "connectome_hull_func.mat",
108
+ ),
109
+ func_=True,
110
+ ) # all there
111
+
112
+ write_connectome_mat(
113
+ PATH_Fingerprints=r"D:\Connectome_RMAP_OUT\hull\struc\HCP1000 6K",
114
+ PATH_CONNECTOME=os.path.join(
115
+ "py_neuromodulation",
116
+ "ConnectivityDecoding",
117
+ "connectome_hull_struc.mat",
118
+ ),
119
+ ) # 5 missing
@@ -0,0 +1,6 @@
1
+ References
2
+ ----------
3
+ Appelhoff, S., Sanderson, M., Brooks, T., Vliet, M., Quentin, R., Holdgraf, C., Chaumon, M., Mikulan, E., Tavabi, K., Höchenberger, R., Welke, D., Brunner, C., Rockhill, A., Larson, E., Gramfort, A. and Jas, M. (2019). MNE-BIDS: Organizing electrophysiological data into the BIDS format and facilitating their analysis. Journal of Open Source Software 4: (1896). https://doi.org/10.21105/joss.01896
4
+
5
+ Holdgraf, C., Appelhoff, S., Bickel, S., Bouchard, K., D'Ambrosio, S., David, O., … Hermes, D. (2019). iEEG-BIDS, extending the Brain Imaging Data Structure specification to human intracranial electrophysiology. Scientific Data, 6, 102. https://doi.org/10.1038/s41597-019-0105-7
6
+
@@ -0,0 +1,8 @@
1
+ {
2
+ "Name": " ",
3
+ "BIDSVersion": "1.7.0",
4
+ "DatasetType": "raw",
5
+ "Authors": [
6
+ "[Unspecified]"
7
+ ]
8
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "participant_id": {
3
+ "Description": "Unique participant identifier"
4
+ },
5
+ "age": {
6
+ "Description": "Age of the participant at time of testing",
7
+ "Units": "years"
8
+ },
9
+ "sex": {
10
+ "Description": "Biological sex of the participant",
11
+ "Levels": {
12
+ "F": "female",
13
+ "M": "male"
14
+ }
15
+ },
16
+ "hand": {
17
+ "Description": "Handedness of the participant",
18
+ "Levels": {
19
+ "R": "right",
20
+ "L": "left",
21
+ "A": "ambidextrous"
22
+ }
23
+ },
24
+ "weight": {
25
+ "Description": "Body weight of the participant",
26
+ "Units": "kg"
27
+ },
28
+ "height": {
29
+ "Description": "Body height of the participant",
30
+ "Units": "m"
31
+ }
32
+ }
@@ -0,0 +1,2 @@
1
+ participant_id age sex hand weight height
2
+ sub-testsub n/a n/a n/a n/a n/a
@@ -0,0 +1,5 @@
1
+ {
2
+ "iEEGCoordinateSystem": "Other",
3
+ "iEEGCoordinateSystemDescription": "n/a",
4
+ "iEEGCoordinateUnits": "m"
5
+ }
@@ -0,0 +1,11 @@
1
+ name x y z size impedance
2
+ LFP_RIGHT_0 0.0118280802308701 -0.0151597482742092 -0.00776909845640809 n/a n/a
3
+ LFP_RIGHT_1 0.0123908351968705 -0.0142925082817827 -0.0059367986990887 n/a n/a
4
+ LFP_RIGHT_2 0.012930849148285701 -0.0134128499400548 -0.00409165661961333 n/a n/a
5
+ ECOG_RIGHT_0 0.037318173999999996 -0.048610126639999994 0.06179765474 n/a n/a
6
+ ECOG_RIGHT_1 0.0401598943 -0.037315929830000004 0.06431171618 n/a n/a
7
+ ECOG_RIGHT_2 0.040943035780000005 -0.02721778456 0.06409518407999999 n/a n/a
8
+ ECOG_RIGHT_3 0.03978395522 -0.01700523081 0.06386618136 n/a n/a
9
+ ECOG_RIGHT_4 0.03968813641 -0.005528024572 0.06168254254 n/a n/a
10
+ ECOG_RIGHT_5 0.03751915924 0.004304913414 0.060541263549999995 n/a n/a
11
+ MOV_RIGHT n/a n/a n/a n/a n/a
@@ -0,0 +1,11 @@
1
+ name type units low_cutoff high_cutoff description sampling_frequency status status_description
2
+ LFP_RIGHT_0 DBS µV 0.0 500.0 Deep Brain Stimulation 1000.0 good n/a
3
+ LFP_RIGHT_1 DBS µV 0.0 500.0 Deep Brain Stimulation 1000.0 good n/a
4
+ LFP_RIGHT_2 DBS µV 0.0 500.0 Deep Brain Stimulation 1000.0 good n/a
5
+ ECOG_RIGHT_0 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
6
+ ECOG_RIGHT_1 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
7
+ ECOG_RIGHT_2 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
8
+ ECOG_RIGHT_3 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
9
+ ECOG_RIGHT_4 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
10
+ ECOG_RIGHT_5 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
11
+ MOV_RIGHT MISC µV 0.0 500.0 Miscellaneous 1000.0 good n/a
@@ -0,0 +1,18 @@
1
+ {
2
+ "TaskName": "gripforce",
3
+ "Manufacturer": "Brain Products",
4
+ "PowerLineFrequency": 60.0,
5
+ "SamplingFrequency": 1000.0,
6
+ "SoftwareFilters": "n/a",
7
+ "RecordingDuration": 19.0,
8
+ "RecordingType": "continuous",
9
+ "iEEGReference": "n/a",
10
+ "ECOGChannelCount": 6,
11
+ "SEEGChannelCount": 3,
12
+ "EEGChannelCount": 0,
13
+ "EOGChannelCount": 0,
14
+ "ECGChannelCount": 0,
15
+ "EMGChannelCount": 0,
16
+ "MiscChannelCount": 1,
17
+ "TriggerChannelCount": 0
18
+ }
@@ -0,0 +1,35 @@
1
+ Brain Vision Data Exchange Header File Version 1.0
2
+ ; Written using pybv 0.7.5
3
+
4
+ [Common Infos]
5
+ Codepage=UTF-8
6
+ DataFile=sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.eeg
7
+ MarkerFile=sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vmrk
8
+ DataFormat=BINARY
9
+ ; Data orientation: MULTIPLEXED=ch1,pt1, ch2,pt1 ...
10
+ DataOrientation=MULTIPLEXED
11
+ NumberOfChannels=10
12
+ ; Sampling interval in microseconds
13
+ SamplingInterval=1000.0
14
+
15
+ [Binary Infos]
16
+ BinaryFormat=IEEE_FLOAT_32
17
+
18
+ [Channel Infos]
19
+ ; Each entry: Ch<Channel number>=<Name>,<Reference channel name>,
20
+ ; <Resolution in "Unit">,<Unit>, Future extensions..
21
+ ; Fields are delimited by commas, some fields might be omitted (empty).
22
+ ; Commas in channel names are coded as "\1".
23
+ Ch1=LFP_RIGHT_0,,0.1,µV
24
+ Ch2=LFP_RIGHT_1,,0.1,µV
25
+ Ch3=LFP_RIGHT_2,,0.1,µV
26
+ Ch4=ECOG_RIGHT_0,,0.1,µV
27
+ Ch5=ECOG_RIGHT_1,,0.1,µV
28
+ Ch6=ECOG_RIGHT_2,,0.1,µV
29
+ Ch7=ECOG_RIGHT_3,,0.1,µV
30
+ Ch8=ECOG_RIGHT_4,,0.1,µV
31
+ Ch9=ECOG_RIGHT_5,,0.1,µV
32
+ Ch10=MOV_RIGHT,,0.1,µV
33
+
34
+ [Comment]
35
+
@@ -0,0 +1,13 @@
1
+ Brain Vision Data Exchange Marker File, Version 1.0
2
+ ; Exported using pybv 0.7.5
3
+
4
+ [Common Infos]
5
+ Codepage=UTF-8
6
+ DataFile=sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.eeg
7
+
8
+ [Marker Infos]
9
+ ; Each entry: Mk<Marker number>=<Type>,<Description>,<Position in data points>,
10
+ ; <Size in data points>, <Channel number (0 = marker is related to all channels)>
11
+ ; <Date (YYYYMMDDhhmmssuuuuuu)>
12
+ ; Fields are delimited by commas, some fields might be omitted (empty).
13
+ ; Commas in type or description text are coded as "\1".
@@ -0,0 +1,2 @@
1
+ filename acq_time
2
+ ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vhdr n/a
@@ -0,0 +1,40 @@
1
+ x y z
2
+ -13.1 -67.7 69.1
3
+ -35.5 -60.0 66.0
4
+ -48.3 -55.1 58.2
5
+ -60.0 -51.8 48.0
6
+ -16.9 -51.6 78.0
7
+ -34.8 -49.3 71.7
8
+ -67.5 -47.1 31.0
9
+ -46.1 -43.7 61.1
10
+ -59.8 -39.6 53.3
11
+ -14.2 -39.1 81.1
12
+ -28.3 -31.2 76.0
13
+ -42.3 -30.7 70.2
14
+ -67.6 -30.1 41.2
15
+ -50.5 -24.4 64.4
16
+ -14.6 -22.7 80.2
17
+ -60.9 -18.7 50.9
18
+ -31.6 -16.9 75.2
19
+ -5.1 -12.6 77.3
20
+ -65.6 -10.8 37.8
21
+ -41.8 -10.2 67.0
22
+ -55.1 -4.01 53.2
23
+ -22.7 1.2 72.0
24
+ -5.8 2.8 74.8
25
+ -49.2 3.7 54.7
26
+ -34.5 3.9 66.5
27
+ -61.55 6.2 35.9
28
+ -63.6 8.3 25.7
29
+ -40.4 11.8 60.7
30
+ -48.7 14.5 50.5
31
+ -21.8 16.0 68.9
32
+ -58.2 18.2 27.3
33
+ -7.0 18.4 70.3
34
+ -36.3 19.9 59.6
35
+ -48.1 24.6 44.0
36
+ -56.8 28.52 20.8
37
+ -7.3 33.8 61.7
38
+ -22.2 35.0 57.2
39
+ -36.8 35.4 47.0
40
+ -46.8 35.6 36.0