-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f644a97
commit dae160f
Showing
13 changed files
with
4,480 additions
and
661 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,65 @@ | ||
#include <stdlib.h> | ||
#include <limits.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <math.h> | ||
#include <string.h> | ||
#include "radixsort.h" | ||
#ifdef _MSC_VER | ||
|
||
#else | ||
#include <unistd.h> | ||
#endif | ||
#include <stdint.h> | ||
|
||
#define printfd(...) fprintf(stderr, __VA_ARGS__) | ||
|
||
#ifndef MAX | ||
#define MAX(A,B) ((A) > (B) ? (A) : (B)) | ||
#endif | ||
|
||
#ifndef MIN | ||
#define MIN(A,B) ((A) > (B) ? (B) : (A)) | ||
#endif | ||
|
||
float fdr(float *pvals, double qval, size_t nvox) { | ||
double cV = 1.0; | ||
if ((qval < 0.0) || (qval > 1.0)) { | ||
printfd("qval out of range (0-1).\n"); | ||
return NAN; | ||
} | ||
//========[PART 1: FDR THRESHOLD]======================================== | ||
//Sort p-values | ||
float* dx_out = (float*)malloc(nvox*sizeof(float)); | ||
uint32_t* idx_in = (uint32_t*)malloc(nvox*sizeof(uint32_t)); | ||
uint32_t* idx_out = (uint32_t*)malloc(nvox*sizeof(uint32_t)); | ||
float mn = pvals[0]; | ||
float mx = pvals[0]; | ||
for (int i = 0; i < nvox; i++) { | ||
idx_in[i] = i; | ||
mn = MIN(mn, pvals[i]); | ||
mx = MAX(mx, pvals[i]); | ||
} | ||
if ((mn < 0.0) || (mx > 1.0)) { | ||
printfd("Values out of range (0-1).\n"); | ||
return NAN; | ||
} | ||
radix11sort_f32(pvals, dx_out, idx_in, idx_out, nvox); | ||
free(idx_in); | ||
free(idx_out); | ||
|
||
// Order (indices), in the same size as the pvalues | ||
int v = 0; | ||
do { | ||
int v2 = v; | ||
do { | ||
v2++; | ||
} while ( v2 < nvox ); | ||
v++; | ||
} while ( v < nvox ); | ||
|
||
free(dx_out); | ||
float thresh = 66.0; | ||
return thresh; | ||
} | ||
|
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,16 @@ | ||
#ifndef EX_FDR_H | ||
#define EX_FDR_H | ||
|
||
#ifdef __cplusplus | ||
//extern "C" { | ||
#endif | ||
|
||
#include <stdbool.h> | ||
|
||
float fdr(float *pvals, double qval, size_t nvox); | ||
|
||
#ifdef __cplusplus | ||
//} | ||
#endif | ||
|
||
#endif // EX_FDR_H |
Oops, something went wrong.