File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,6 @@ function getFiles (dir, files_){
109
109
* header without reading any extra bytes.
110
110
*/
111
111
function readNiftiHeader ( file , callback ) {
112
-
113
112
var bytesRead = 500 ;
114
113
115
114
if ( fs ) {
@@ -126,7 +125,11 @@ function readNiftiHeader (file, callback) {
126
125
fs . createReadStream ( file . path , { start : 0 , end : bytesRead , chunkSize : bytesRead + 1 } )
127
126
. on ( 'data' , function ( chunk ) {
128
127
fileBuffer = chunk ;
129
- decompressStream . write ( chunk ) ;
128
+ if ( file . name . endsWith ( '.nii' ) ) {
129
+ callback ( nifti . parseNIfTIHeader ( chunk ) ) ;
130
+ } else {
131
+ decompressStream . write ( chunk ) ;
132
+ }
130
133
} ) ;
131
134
132
135
} else {
@@ -144,12 +147,16 @@ function readNiftiHeader (file, callback) {
144
147
var buffer = new Uint8Array ( fileReader . result ) ;
145
148
var unzipped ;
146
149
147
- try {
148
- unzipped = pako . inflate ( buffer ) ;
149
- }
150
- catch ( err ) {
151
- callback ( handleGunzipError ( buffer , file ) ) ;
152
- return ;
150
+ if ( file . name . endsWith ( '.nii' ) ) {
151
+ unzipped = buffer ;
152
+ } else {
153
+ try {
154
+ unzipped = pako . inflate ( buffer ) ;
155
+ }
156
+ catch ( err ) {
157
+ callback ( handleGunzipError ( buffer , file ) ) ;
158
+ return ;
159
+ }
153
160
}
154
161
155
162
callback ( nifti . parseNIfTIHeader ( unzipped ) ) ;
You can’t perform that action at this time.
0 commit comments