Skip to content

Commit

Permalink
Merge pull request #47 from natacha-beck/bb_hdf-5
Browse files Browse the repository at this point in the history
BrainBrowser read directly HDF5 file
  • Loading branch information
prioux committed Apr 28, 2016
2 parents 903ce1e + 8390a43 commit e9e1f8e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
6 changes: 6 additions & 0 deletions userfiles/minc1_file/minc1_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ def self.pretty_type #:nodoc:
"Minc1 File"
end

# Overwrite the method in order to
# call the "volume_viewer_loader" of MincFile
def view_path(partial_name=nil)
MincFile.view_path(partial_name)
end

end

6 changes: 6 additions & 0 deletions userfiles/minc2_file/minc2_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ def has_minctools?(min_version=[2,0,0],which_tools=["mincinfo", "minctoraw"]) #
super
end

# Overwrite the method in order to
# call the "volume_viewer_loader" of MincFile
def view_path(partial_name=nil)
MincFile.view_path(partial_name)
end

end

10 changes: 10 additions & 0 deletions userfiles/minc_file/minc_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class MincFile < SingleFile

has_content :method => :get_headers_to_json, :type => :text
has_content :method => :get_raw_data, :type => :text
has_content :method => :raw_content, :type => :text

def self.file_name_pattern #:nodoc:
/\.mi?nc(\.gz|\.Z|\.gz2)?$/i
Expand Down Expand Up @@ -115,6 +116,15 @@ def get_raw_data #:nodoc:
@raw_data = IO.popen("minctoraw -byte -unsigned -normalize #{escaped_path}") { |fh| fh.readlines.join }
end

#For content
def raw_content
if self.name =~ /(\.gz|\.Z|\.gz2)$/i
IO.popen("gunzip -c #{self.cache_full_path.to_s.bash_escape}") { |fh| fh.readlines.join }
else
File.open(self.cache_full_path, "r").read
end
end

def minc_get_data #:nodoc:
@data ||= self.raw_data.unpack('v*') #Unpack is used here to convert 4 byte(char) to a short unsigned integer
end
Expand Down
4 changes: 2 additions & 2 deletions userfiles/minc_file/views/_volume_viewer_loader.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ viewer.loadVolumes({
volumes: [
{
type: "minc",
header_url: "<%= content_userfile_path(@userfile) + "?content_loader=get_headers_to_json" %>",
raw_data_url: "<%= content_userfile_path(@userfile) + "?content_loader=get_raw_data" %>",
header_url: "",
raw_data_url: "<%= content_userfile_path(@userfile) + "?content_loader=raw_content" %>",
},
],
complete: function() {
Expand Down

Large diffs are not rendered by default.

0 comments on commit e9e1f8e

Please sign in to comment.