-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1797 from effigies/enh/associations
ENH: Finish populating associations
- Loading branch information
Showing
4 changed files
with
130 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* DWI | ||
* Module for parsing DWI-associated files | ||
*/ | ||
const normalizeEOL = (str: string): string => | ||
str.replace(/\r\n/g, '\n').replace(/\r/g, '\n') | ||
|
||
export function parseBval(contents: string): number[][] { | ||
// BVAL files are a single row of numbers, and may contain | ||
// trailing whitespace | ||
return [contents | ||
.split(/\s+/) | ||
.filter((x) => x !== '') | ||
.map((x) => Number(x))] | ||
} | ||
|
||
export function parseBvec(contents: string): number[][] { | ||
// BVEC files are a matrix of numbers, with each row being | ||
// a different axis | ||
return normalizeEOL(contents) | ||
.split(/\s*\n/) | ||
.filter((x) => x !== '') | ||
.map((row) => | ||
row | ||
.split(/\s+/) | ||
.filter((x) => x !== '') | ||
.map((x) => Number(x)), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters