From 5b11ea76c772f670eac6bbaa8b3010ef4a69a50f Mon Sep 17 00:00:00 2001 From: nikitas-k Date: Thu, 7 Nov 2024 11:42:14 +1100 Subject: [PATCH] enforce merge --- eigenstrapping/base.py | 117 ++++++++++------ eigenstrapping/datasets/osf.json | 226 ++++++++++++++++++++----------- eigenstrapping/datasets/utils.py | 9 +- eigenstrapping/geometry.py | 2 +- 4 files changed, 228 insertions(+), 126 deletions(-) diff --git a/eigenstrapping/base.py b/eigenstrapping/base.py index 4a88250..3f55dfd 100644 --- a/eigenstrapping/base.py +++ b/eigenstrapping/base.py @@ -16,7 +16,10 @@ from .geometry import (calc_surface_eigenmodes, get_tkrvox2ras, - make_tetra) + make_tetra, + spin_single, + gen_eigensamples, + truncate_emodes) import copy @@ -311,7 +314,10 @@ def __init__(self, data, surface=None, evals=None, emodes=None, num_modes=200, save_surface=False, seed=None, decomp_method='matrix', medial=None, randomize=False, resample=False, n_jobs=1, use_cholmod=False, permute=False, add_res=False, - save_rotations=False, parcellation=None, normalize=True): + truncate_modes=False, ret_fwhm=False, truncate_args=None, + save_rotations=False, parcellation=None, + normalize=True, use_nn=False, nn_method='original', + eigen_perms=None): # initialization of variables if surface is None: @@ -347,6 +353,11 @@ def __init__(self, data, surface=None, evals=None, emodes=None, num_modes=200, self.save_rotations = save_rotations self.parcellation = parcellation self.normalize = normalize + self.truncate_modes = truncate_modes + self.use_nn = use_nn + self.nn_method = nn_method + self.eigen_perms = eigen_perms + self.truncate_args = truncate_args self._lm = LinearRegression(fit_intercept=True) self.add_res = add_res @@ -417,13 +428,23 @@ def __init__(self, data, surface=None, evals=None, emodes=None, num_modes=200, if self.emodes.shape[1] != self.evals.shape[0]: raise ValueError("There must be as many eigenmodes as there are eigenvalues") + # actually the indices that AREN'T medial wall self.medial_wall = self.medial_wall.astype(np.bool_) - - self.n_vertices = self.emodes.shape[0] - + # actually ARE the indices of medial wall self.medial_mask = np.logical_not(self.medial_wall) + + self.n_vertices = self.emodes.shape[0] + self.data_no_mwall = self.data # deepcopy original data so it's not modified self.data_no_mwall = self.data[self.medial_wall] + + # truncate eigenmodes at nearest eigengroup + if self.truncate_modes: + if self.surface is None: + raise ValueError('in order to compute kernel density estimate for data re:\n' + 'number of modes (groups) to use, surface geometry must be given.') + self.fwhm, self.emodes, self.evals = truncate_emodes(self.data_no_mwall, self.surface, self.emodes, self.evals, mask=self.medial_wall, seed=self._rs, ret_fwhm=self.ret_fwhm, **self.truncate_args) + self._emodes = copy.deepcopy(self.emodes) self._emodes = self._emodes[self.medial_wall] @@ -459,9 +480,11 @@ def __call__(self, n=1): ``self.medial_wall``. """ - if self.save_rotations: - self.rotations = np.zeros((n, *self.emodes.shape)) rs = self._rs.randint(np.iinfo(np.int32).max, size=n) + if self.use_nn is True or self.eigen_perms is not None: + if self.eigen_perms is None: + self.eigen_perms = gen_eigensamples(self.emodes, self.evals, mask=self.medial_wall, num_modes=self.num_modes, + n_rotate=n, method=self.nn_method, n_jobs=self.n_jobs) surrs = np.row_stack( Parallel(self.n_jobs)( delayed(self._call_method)(rs=i) for i in rs @@ -497,33 +520,42 @@ def generate(self, output_modes=False): mask = self.medial_wall coeffs = copy.deepcopy(self.coeffs) reconstructed_data = copy.deepcopy(self.reconstructed_data) - residuals = copy.deepcopy(self.residuals) - - # initialize the new modes - new_modes = np.zeros_like(emodes) - - # resample the hypersphere (except for groups 1 and 2) - for idx in range(len(groups)): - if idx > 100: - gen = True - group_modes = emodes[:, groups[idx]] - group_evals = evals[groups[idx]] - p = group_modes - # else, transform to spheroid and index the angles properly - if self.normalize: - p = transform_to_spheroid(group_evals, group_modes) - - p_rot = self.rotate_modes(p, gen=True) - - # transform back to ellipsoid - if self.normalize: - p_rot = transform_to_ellipsoid(group_evals, p_rot) + #residuals = copy.deepcopy(self.residuals) + + if self.eigen_perms is None: + # initialize the new modes + new_modes = np.zeros_like(emodes) + # resample the hypersphere (except for groups 1 and 2) + for idx in range(len(groups)): + if idx > 100: + gen = True + group_modes = emodes[:, groups[idx]] + group_evals = evals[groups[idx]] + p = group_modes + # else, transform to spheroid and index the angles properly + if self.normalize: + p = transform_to_spheroid(group_evals, group_modes) + + p_rot = self.rotate_modes(p, gen=True) + + # transform back to ellipsoid + if self.normalize: + p_rot = transform_to_ellipsoid(group_evals, p_rot) + + new_modes[:, groups[idx]] = p_rot - new_modes[:, groups[idx]] = p_rot - - if output_modes: - return new_modes + if output_modes: + return new_modes + else: + new_modes = spin_single( + self.emodes, + evals, + mask=mask, + eigen_perms=self.eigen_perms[self._rs.randint(0, len(self.eigen_perms))], + num_modes=self.num_modes, + return_masked=True, + ) # matrix multiply the estimated coefficients by the new modes surrogate = np.zeros_like(self.data)*np.nan # original data @@ -538,13 +570,6 @@ def generate(self, output_modes=False): # Mask the data and surrogate_data excluding the medial wall surr_no_mwall = copy.deepcopy(surrogate) surr_no_mwall = surr_no_mwall[mask] - - # now add the residuals of the original data - if self.permute: - surr_no_mwall += self._rs.permutation(residuals) - - if self.add_res: - surr_no_mwall += residuals # if self.resample: # # Get the rank ordered indices @@ -558,9 +583,19 @@ def generate(self, output_modes=False): sorted_map = np.sort(data) ii = np.argsort(surr_no_mwall) np.put(surr_no_mwall, ii, sorted_map) - else: # demean - surr_no_mwall = surr_no_mwall - np.nanmean(surr_no_mwall) + else: # force match the minimum and maximum + sf = (np.nanmax(data) - np.nanmin(data)) / (np.nanmax(surr_no_mwall) - np.nanmin(surr_no_mwall)) + shift = np.nanmin(data) - sf * np.nanmin(surr_no_mwall) + surr_no_mwall = surr_no_mwall * sf + shift + + # now add the residuals of the original data + residuals = data - surr_no_mwall + if self.permute: + surr_no_mwall += self._rs.permutation(residuals) + if self.add_res: + surr_no_mwall += residuals + # else: # force match the minima # indices = np.nonzero(surr_no_mwall)[0] # Indices where s is non-zero diff --git a/eigenstrapping/datasets/osf.json b/eigenstrapping/datasets/osf.json index 8163489..e09b631 100644 --- a/eigenstrapping/datasets/osf.json +++ b/eigenstrapping/datasets/osf.json @@ -12,6 +12,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65668211a7a4834d7f714286" ] }, @@ -27,6 +28,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "" ] }, @@ -43,6 +45,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65668164932b9f48ad7607c6" ] }, @@ -59,6 +62,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "" ] } @@ -71,12 +75,13 @@ "format": "emodes", "fname": "space-fsaverage_den-3k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "a6aa282ce0f0166f9f2caf83bee4e0d0", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123e8e5e51c0f90bc57cb" + "googledrive", + "668ded7cc727f8001c5b864d" ] }, { @@ -86,12 +91,13 @@ "format": "evals", "fname": "space-fsaverage_den-3k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "e92ed624d364b298ac8377b5232d7c1c", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123e68992ec0f987886ae" + "googledrive", + "6684c5b36f01f301812cf024" ] }, { @@ -101,12 +107,13 @@ "format": "emodes", "fname": "space-fsaverage_den-3k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "5ecadc7c59df4aceefe31457781cb570", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123e84dfd8c0f3827f864" + "googledrive", + "668ded7cc727f8001c5b8649" ] }, { @@ -116,12 +123,13 @@ "format": "evals", "fname": "space-fsaverage_den-3k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "9df8db72993bb9a9a6a3df06febf1b5d", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123e5719c060f78d49d7d" + "googledrive", + "6684c5b36f01f301812cf022" ] }, { @@ -131,12 +139,13 @@ "format": "emodes", "fname": "space-fsaverage_den-10k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "81b1772209132b99d85667f533c4ce7f", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "6566812ff0b8e24c97a9d80c" + "googledrive", + "668ded7cc727f8001c5b865f" ] }, { @@ -146,12 +155,13 @@ "format": "evals", "fname": "space-fsaverage_den-10k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "731e0381d943c7dfb641b3b323c68eff", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "6566812479d42829de3e864c" + "googledrive", + "6684c5b36f01f301812cf030" ] }, { @@ -161,12 +171,13 @@ "format": "emodes", "fname": "space-fsaverage_den-10k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "28aa886f8c210c1d30dffac2c2018a8e", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "6566812ef0b8e24c97a9d80a" + "googledrive", + "668ded7cc727f8001c5b865c" ] }, { @@ -176,12 +187,13 @@ "format": "evals", "fname": "space-fsaverage_den-10k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "4bac654fa66eccf2089646c841549ddb", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65668124932b9f48b276087f" + "googledrive", + "6684c5b36f01f301812cf02e" ] }, { @@ -191,12 +203,13 @@ "format": "emodes", "fname": "space-fsaverage_den-41k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "e5a9171b8da679d03d0513c80972df32", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1243e8520370f70880456" + "googledrive", + "668ded7cc727f8001c5b8658" ] }, { @@ -206,12 +219,13 @@ "format": "evals", "fname": "space-fsaverage_den-41k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "24ae270a1c9533143f6114cbbecbaccf", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123eb8520370f74880174" + "googledrive", + "6684c5b36f01f301812cf02c" ] }, { @@ -221,12 +235,13 @@ "format": "emodes", "fname": "space-fsaverage_den-41k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "57fe24dca37ac30dd2648e5e2108bb66", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1243d719c060f78d49da3" + "googledrive", + "668ded7cc727f8001c5b8656" ] }, { @@ -236,12 +251,13 @@ "format": "evals", "fname": "space-fsaverage_den-41k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "5d2a77f359e924a0ec4d9dacba3edbc4", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123ec8520370f70880428" + "googledrive", + "6684c5b36f01f301812cf02a" ] }, { @@ -251,12 +267,13 @@ "format": "emodes", "fname": "space-fsaverage_den-164k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "6f2c37cbd2ae979c4570fd662ec58d4b", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1257ce5e51c0f94bc5508" + "googledrive", + "668ded7cc727f8001c5b8652" ] }, { @@ -266,12 +283,13 @@ "format": "evals", "fname": "space-fsaverage_den-164k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "b7b840ffa52e6660fac5e7705e2b9ebf", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123fa8520370f74880183" + "googledrive", + "6684c5b36f01f301812cf028" ] }, { @@ -281,12 +299,13 @@ "format": "emodes", "fname": "space-fsaverage_den-164k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "884ac3d2700af219cb1f0d42de984159", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1257ee5e51c0f94bc550a" + "googledrive", + "668ded7cc727f8001c5b864f" ] }, { @@ -296,12 +315,13 @@ "format": "evals", "fname": "space-fsaverage_den-164k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "ef654df66341bcfa3c53dc8afa9dbd19", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f123fe4dfd8c0f3827f868" + "googledrive", + "6684c5b36f01f301812cf026" ] }, { @@ -311,12 +331,13 @@ "format": "emodes", "fname": "space-fsLR_den-4k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "72d4411a3c914de40fd503d3bdf31561", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f124098992ec0fa978857a" + "googledrive", + "668ded7cc727f8001c5b8646" ] }, { @@ -326,12 +347,13 @@ "format": "evals", "fname": "space-fsLR_den-4k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "729d6cbae84aac9b6b06eb405f31dc8c", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1240e8520370f61880392" + "googledrive", + "6684c5b36f01f301812cf020" ] }, { @@ -341,12 +363,13 @@ "format": "emodes", "fname": "space-fsLR_den-4k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "a3733cc068ccc5d68f26653445598ac5", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1241c8992ec0fa9788589" + "googledrive", + "668ded7cc727f8001c5b8644" ] }, { @@ -356,12 +379,13 @@ "format": "evals", "fname": "space-fsLR_den-4k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "9a814eb3d4f99c8b42fbbe59ec53f2ab", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f12420719c060f87d4a05a" + "googledrive", + "6684c5b36f01f301812cf01e" ] }, { @@ -371,12 +395,13 @@ "format": "emodes", "fname": "space-fsLR_den-8k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "1bb4a1c7dc6f7e6adc38d36772d8a0a7", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f12437e5e51c0f85bc5ac8" + "googledrive", + "668ded7cc727f8001c5b8640" ] }, { @@ -386,12 +411,13 @@ "format": "evals", "fname": "space-fsLR_den-8k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "6d279d7887fc80c3ff12cc1c89ea1f13", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1243c719c060f87d4a06d" + "googledrive", + "6684c5b36f01f301812cf01c" ] }, { @@ -401,12 +427,13 @@ "format": "emodes", "fname": "space-fsLR_den-8k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "dcab069e2b353db94899e3b65a7b3ddf", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f124528520370f748801a8" + "googledrive", + "668ded7cc727f8001c5b863d" ] }, { @@ -416,12 +443,13 @@ "format": "evals", "fname": "space-fsLR_den-8k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "4e8a91bcf1a6b391a8a92a14a6912d11", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f124428992ec0fa5788a6b" + "googledrive", + "6684c5b36f01f301812cf01a" ] }, { @@ -431,12 +459,13 @@ "format": "emodes", "fname": "space-fsLR_den-32k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "c6d0b329011d368a911f27ba7ff4df6a", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "656928cc02fa96017e7d2a14" + "googledrive", + "668ded7cc727f8001c5b863a" ] }, { @@ -446,12 +475,13 @@ "format": "evals", "fname": "space-fsLR_den-32k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "8260ab841726bbc1d456b185a87b1665", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "6569284a5022f6018f88ea99" + "googledrive", + "6684c5b36f01f301812cf018" ] }, { @@ -461,12 +491,13 @@ "format": "emodes", "fname": "space-fsLR_den-32k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "ffaddb605918978cda7194d1a9153597", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "656928db02fa96017e7d2a1e" + "googledrive", + "668ded7cc727f8001c5b8638" ] }, { @@ -476,12 +507,13 @@ "format": "evals", "fname": "space-fsLR_den-32k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "b5c74a9127636ecdfb2119750d19708b", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "6569285f02fa9601827d2e2b" + "googledrive", + "6684c5b36f01f301812cf016" ] }, { @@ -491,12 +523,13 @@ "format": "emodes", "fname": "space-fsLR_den-164k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "6f2c37cbd2ae979c4570fd662ec58d4b", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1257ce5e51c0f94bc5508" + "googledrive", + "668ded7cc727f8001c5b8635" ] }, { @@ -506,12 +539,13 @@ "format": "evals", "fname": "space-fsLR_den-164k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "78b8d4c3ace9334abcba39b42ca8ce9a", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f12446719c060f8bd49aeb" + "googledrive", + "6684c5b36f01f301812cf014" ] }, { @@ -521,12 +555,13 @@ "format": "emodes", "fname": "space-fsLR_den-164k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "884ac3d2700af219cb1f0d42de984159", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f1257ee5e51c0f94bc550a" + "googledrive", + "668ded7cc727f8001c5b8631" ] }, { @@ -536,12 +571,13 @@ "format": "evals", "fname": "space-fsLR_den-164k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "e07c3f1dbf5dadcc5bbaf1feaf1bd160", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f124554dfd8c0f3727f75c" + "googledrive", + "6684c5b36f01f301812cf012" ] }, { @@ -551,12 +587,13 @@ "format": "emodes", "fname": "space-civet_den-41k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "50d2d9f2bec51067da1393d868d553c6", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f125d14dfd8c0f4627f613" + "googledrive", + "668ded7cc727f8001c5b8628" ] }, { @@ -566,12 +603,13 @@ "format": "evals", "fname": "space-civet_den-41k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "69b2aef1b7c5234545c496cae1fde3a2", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f125a2e5e51c0f82bc5872" + "googledrive", + "6684c5b36f01f301812cf00c" ] }, { @@ -581,12 +619,13 @@ "format": "emodes", "fname": "space-civet_den-41k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "b2ca361884de06cc9737e4c9e0294647", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f125d28992ec0fa5788af9" + "googledrive", + "668ded7cc727f8001c5b8625" ] }, { @@ -596,12 +635,13 @@ "format": "evals", "fname": "space-civet_den-41k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "292f2678f838b61e1e8260c363ce2f69", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f125a18992ec0fa978865c" + "googledrive", + "6684c5b36f01f301812cf00a" ] }, { @@ -611,12 +651,13 @@ "format": "emodes", "fname": "space-civet_den-164k_hemi-lh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "ccbeb4179cebba5dc9c11a0314b95a03", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f12a5a4dfd8c0f3727f99c" + "googledrive", + "668ded7cc727f8001c5b862e" ] }, { @@ -626,12 +667,13 @@ "format": "evals", "fname": "space-civet_den-164k_hemi-lh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "1d7223906d2c83ca042a3299d44c66bb", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f129fd8520370f70880861" + "googledrive", + "6684c5b36f01f301812cf010" ] }, { @@ -641,12 +683,13 @@ "format": "emodes", "fname": "space-civet_den-164k_hemi-rh_emodes.txt", "rel_path": "eigenmodes/", - "checksum": "5a2f75f800fc4b7f04966d74b1694b71", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f12d514dfd8c0f4b27f76b" + "googledrive", + "668ded7cc727f8001c5b862b" ] }, { @@ -656,12 +699,13 @@ "format": "evals", "fname": "space-civet_den-164k_hemi-rh_evals.txt", "rel_path": "eigenmodes/", - "checksum": "f351cbf1a489834ef47f773e4f9ab702", + "checksum": null, "title": null, "redir": null, "url": [ "mabr9", - "65f12cf28520370f628807ea" + "googledrive", + "6684c5b36f01f301812cf00e" ] } ], @@ -678,6 +722,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65668144aa3a762736d6ab2b" ] }, @@ -693,6 +738,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65668144932b9f48b2760891" ] }, @@ -705,6 +751,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c28879d4282a903e8365" ] }, @@ -720,6 +767,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c28879d4282a903e8365" ] }, @@ -735,6 +783,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65692b63a0121a0190317a60" ] } @@ -750,6 +799,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -765,6 +815,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -780,6 +831,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -795,6 +847,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -810,6 +863,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -825,6 +879,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -840,6 +895,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] } @@ -857,6 +913,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -872,6 +929,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -887,6 +945,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -902,6 +961,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -917,6 +977,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] }, @@ -932,6 +993,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "6566c25caa3a7627e8d6aabb" ] } @@ -949,6 +1011,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65e92b1385203706eb8802c3" ] }, @@ -963,6 +1026,7 @@ "redir": null, "url": [ "mabr9", + "osfstorage", "65e92b13e5e51c06dfbc54c7" ] } @@ -970,4 +1034,4 @@ ] -} \ No newline at end of file +} diff --git a/eigenstrapping/datasets/utils.py b/eigenstrapping/datasets/utils.py index ef58710..28dd2e8 100644 --- a/eigenstrapping/datasets/utils.py +++ b/eigenstrapping/datasets/utils.py @@ -61,7 +61,8 @@ def _osfify_urls(data): Input data with all `url` dict keys formatted """ - OSF_API = "https://files.osf.io/v1/resources/{}/providers/osfstorage/{}" + OSF_API = "https://files.osf.io/v1/resources/{}/providers/{}/{}" + DRIVE_FORMAT = "https://osf.io/download/{}" if isinstance(data, str) or data is None: return data @@ -72,6 +73,8 @@ def _osfify_urls(data): # if the url isn't a string assume we're supposed to format it elif not isinstance(data['url'], str): data['url'] = OSF_API.format(*data['url']) + if 'googledrive' in data['url']: + data['url'] = DRIVE_FORMAT.format(data['url'].split('/')[-1]) try: for key, value in data.items(): @@ -81,7 +84,7 @@ def _osfify_urls(data): data[n] = _osfify_urls(value) # drop the invalid entries data = [d for d in data if d is not None] - + return data def get_data_dir(data_dir=None): @@ -190,4 +193,4 @@ def get_dataset_info(name): raise KeyError("Provided dataset '{}' is not valid. Must be one of: {}" .format(name, sorted(osf_resources.keys()))) - return resource \ No newline at end of file + return resource diff --git a/eigenstrapping/geometry.py b/eigenstrapping/geometry.py index 8fbdea6..7a0c4af 100644 --- a/eigenstrapping/geometry.py +++ b/eigenstrapping/geometry.py @@ -1019,7 +1019,7 @@ def find_wavelength(surface, data, roi=None, column=None, demean=True): os.unlink(tmpf) - return 2*float(output[0].decode('ascii').split(' ')[1]) + return 2*np.pi*float(output[0].decode('ascii').split(' ')[1]) def truncate_emodes(surface, data, emodes, evals, mask=None, ret_fwhm=False, find_group_only=False,