Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Core_Extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Core_Extension
Commits
35ebb9ce
Commit
35ebb9ce
authored
Jun 23, 2014
by
Tobias Pietzsch
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'github/towards-spimdata' into towards-spimdata
parents
0372589d
5122cea2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fiji/src/main/java/bdv/ij/ResavePlugin.java
+133
-93
133 additions, 93 deletions
fiji/src/main/java/bdv/ij/ResavePlugin.java
with
133 additions
and
93 deletions
fiji/src/main/java/bdv/ij/ResavePlugin.java
+
133
−
93
View file @
35ebb9ce
...
...
@@ -17,6 +17,10 @@ import javax.swing.JFileChooser;
import
javax.swing.filechooser.FileFilter
;
import
mpicbg.spim.data.SpimDataException
;
import
mpicbg.spim.data.generic.AbstractSpimData
;
import
mpicbg.spim.data.generic.XmlIoAbstractSpimData
;
import
mpicbg.spim.data.generic.sequence.AbstractSequenceDescription
;
import
mpicbg.spim.data.sequence.ImgLoader
;
import
bdv.export.ExportMipmapInfo
;
import
bdv.export.ProgressWriter
;
import
bdv.export.ProposeMipmaps
;
...
...
@@ -25,7 +29,6 @@ import bdv.export.WriteSequenceToHdf5;
import
bdv.ij.util.PluginHelper
;
import
bdv.ij.util.ProgressWriterIJ
;
import
bdv.img.hdf5.Hdf5ImageLoader
;
import
bdv.spimdata.SequenceDescriptionMinimal
;
import
bdv.spimdata.SpimDataMinimal
;
import
bdv.spimdata.XmlIoSpimDataMinimal
;
...
...
@@ -36,17 +39,13 @@ public class ResavePlugin implements PlugIn
new
ResavePlugin
().
run
(
null
);
}
p
rotected
static
class
Parameters
p
ublic
static
class
Parameters
{
final
boolean
setMipmapManual
;
final
int
[][]
resolutions
;
final
int
[][]
subdivisions
;
final
File
seqFile
;
final
File
hdf5File
;
boolean
setMipmapManual
;
int
[][]
resolutions
;
int
[][]
subdivisions
;
File
seqFile
;
File
hdf5File
;
public
Parameters
(
final
boolean
setMipmapManual
,
final
int
[][]
resolutions
,
final
int
[][]
subdivisions
,
final
File
seqFile
,
final
File
hdf5File
)
{
...
...
@@ -56,42 +55,27 @@ public class ResavePlugin implements PlugIn
this
.
seqFile
=
seqFile
;
this
.
hdf5File
=
hdf5File
;
}
}
@Override
public
void
run
(
final
String
arg
)
{
final
JFileChooser
fileChooser
=
new
JFileChooser
();
fileChooser
.
setFileFilter
(
new
FileFilter
()
{
@Override
public
String
getDescription
()
{
return
"xml files"
;
public
void
setSeqFile
(
final
File
seqFile
)
{
this
.
seqFile
=
seqFile
;
}
public
void
setHDF5File
(
final
File
hdf5File
)
{
this
.
hdf5File
=
hdf5File
;
}
public
void
setResolutions
(
final
int
[][]
resolutions
)
{
this
.
resolutions
=
resolutions
;
}
public
void
setSubdivisions
(
final
int
[][]
subdivisions
)
{
this
.
subdivisions
=
subdivisions
;
}
public
void
setMipmapManual
(
final
boolean
setMipmapManual
)
{
this
.
setMipmapManual
=
setMipmapManual
;
}
public
File
getSeqFile
()
{
return
seqFile
;
}
public
File
getHDF5File
()
{
return
hdf5File
;
}
public
int
[][]
getResolutions
()
{
return
resolutions
;
}
public
int
[][]
getSubdivisions
()
{
return
subdivisions
;
}
public
boolean
getMipmapManual
()
{
return
setMipmapManual
;
}
}
@Override
public
boolean
accept
(
final
File
f
)
{
if
(
f
.
isDirectory
()
)
return
true
;
if
(
f
.
isFile
()
)
public
void
run
(
final
String
arg
)
{
final
String
s
=
f
.
getName
();
final
int
i
=
s
.
lastIndexOf
(
'.'
);
if
(
i
>
0
&&
i
<
s
.
length
()
-
1
)
{
final
String
ext
=
s
.
substring
(
i
+
1
).
toLowerCase
();
return
ext
.
equals
(
"xml"
);
}
}
return
false
;
}
}
);
final
File
file
=
getInputXML
();
if
(
file
==
null
)
return
;
final
int
returnVal
=
fileChooser
.
showOpenDialog
(
null
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
{
final
File
file
=
fileChooser
.
getSelectedFile
();
final
XmlIoSpimDataMinimal
io
=
new
XmlIoSpimDataMinimal
();
SpimDataMinimal
spimData
;
try
...
...
@@ -105,7 +89,7 @@ public class ResavePlugin implements PlugIn
final
Map
<
Integer
,
ExportMipmapInfo
>
perSetupExportMipmapInfo
=
ProposeMipmaps
.
proposeMipmaps
(
spimData
.
getSequenceDescription
()
);
final
Parameters
params
=
getParameters
(
perSetupExportMipmapInfo
.
get
(
0
)
);
final
Parameters
params
=
getParameters
(
perSetupExportMipmapInfo
.
get
(
0
)
,
true
);
if
(
params
==
null
)
return
;
...
...
@@ -113,37 +97,48 @@ public class ResavePlugin implements PlugIn
progressWriter
.
out
().
println
(
"starting export..."
);
// write hdf5
final
File
seqFile
=
params
.
seqFile
;
final
File
hdf5File
=
params
.
hdf5File
;
writeHDF5
(
spimData
.
getSequenceDescription
(),
params
,
perSetupExportMipmapInfo
,
progressWriter
);
// write xml sequence description
writeXML
(
spimData
,
io
,
params
.
seqFile
,
params
.
hdf5File
,
progressWriter
);
}
public
static
void
writeHDF5
(
final
AbstractSequenceDescription
<
?,
?,
?
>
seq
,
final
Parameters
params
,
final
Map
<
Integer
,
ExportMipmapInfo
>
perSetupExportMipmapInfo
,
final
ProgressWriter
progressWriter
)
{
final
boolean
setMipmapManual
=
params
.
setMipmapManual
;
final
int
[][]
manualResolutions
=
params
.
resolutions
;
final
int
[][]
manualSubdivisions
=
params
.
subdivisions
;
final
SequenceDescriptionMinimal
seq
=
spimData
.
getSequenceDescription
();
if
(
setMipmapManual
)
WriteSequenceToHdf5
.
writeHdf5File
(
seq
,
manualResolutions
,
manualSubdivisions
,
hdf5File
,
new
SubTaskProgressWriter
(
progressWriter
,
0
,
0.95
)
);
WriteSequenceToHdf5
.
writeHdf5File
(
seq
,
manualResolutions
,
manualSubdivisions
,
params
.
hdf5File
,
new
SubTaskProgressWriter
(
progressWriter
,
0
,
0.95
)
);
else
WriteSequenceToHdf5
.
writeHdf5File
(
seq
,
perSetupExportMipmapInfo
,
hdf5File
,
new
SubTaskProgressWriter
(
progressWriter
,
0
,
0.95
)
);
WriteSequenceToHdf5
.
writeHdf5File
(
seq
,
perSetupExportMipmapInfo
,
params
.
hdf5File
,
new
SubTaskProgressWriter
(
progressWriter
,
0
,
0.95
)
);
}
// write xml sequence description
public
static
<
T
extends
AbstractSpimData
<
A
>,
A
extends
AbstractSequenceDescription
<
?,
?,
?
super
ImgLoader
<
?
>
>
>
void
writeXML
(
final
T
spimData
,
final
XmlIoAbstractSpimData
<
A
,
T
>
io
,
final
File
seqFile
,
final
File
hdf5File
,
final
ProgressWriter
progressWriter
)
{
final
A
seq
=
spimData
.
getSequenceDescription
();
final
Hdf5ImageLoader
hdf5Loader
=
new
Hdf5ImageLoader
(
hdf5File
,
null
,
null
,
false
);
seq
.
setImgLoader
(
hdf5Loader
);
final
File
basePath
=
seqFile
.
getParentFile
();
final
SpimDataMinimal
spimData2
=
new
SpimDataMinimal
(
basePath
,
seq
,
spimData
.
getViewRegistrations
()
);
spimData
.
setBasePath
(
seqFile
.
getParentFile
()
);
try
{
io
.
save
(
spimData
2
,
seqFile
.
getAbsolutePath
()
);
io
.
save
(
spimData
,
seqFile
.
getAbsolutePath
()
);
}
catch
(
final
SpimDataException
e
)
{
throw
new
RuntimeException
(
e
);
}
progressWriter
.
setProgress
(
1.0
);
progressWriter
.
out
().
println
(
"done"
);
}
}
static
boolean
lastSetMipmapManual
=
false
;
...
...
@@ -151,9 +146,44 @@ public class ResavePlugin implements PlugIn
static
String
lastChunkSizes
=
"{16,16,16}, {16,16,16}, {16,16,16}"
;
static
String
lastExportPath
=
"/Users/pietzsch/Desktop/spimrec2.xml"
;
public
static
String
lastExportPath
=
"/Users/pietzsch/Desktop/spimrec2.xml"
;
protected
Parameters
getParameters
(
final
ExportMipmapInfo
autoMipmapSettings
)
public
static
File
getInputXML
()
{
final
JFileChooser
fileChooser
=
new
JFileChooser
();
fileChooser
.
setFileFilter
(
new
FileFilter
()
{
@Override
public
String
getDescription
()
{
return
"xml files"
;
}
@Override
public
boolean
accept
(
final
File
f
)
{
if
(
f
.
isDirectory
()
)
return
true
;
if
(
f
.
isFile
()
)
{
final
String
s
=
f
.
getName
();
final
int
i
=
s
.
lastIndexOf
(
'.'
);
if
(
i
>
0
&&
i
<
s
.
length
()
-
1
)
{
final
String
ext
=
s
.
substring
(
i
+
1
).
toLowerCase
();
return
ext
.
equals
(
"xml"
);
}
}
return
false
;
}
}
);
if
(
fileChooser
.
showOpenDialog
(
null
)
==
JFileChooser
.
APPROVE_OPTION
)
return
fileChooser
.
getSelectedFile
();
else
return
null
;
}
public
static
Parameters
getParameters
(
final
ExportMipmapInfo
autoMipmapSettings
,
final
boolean
askForXMLPath
)
{
while
(
true
)
{
...
...
@@ -166,6 +196,7 @@ public class ResavePlugin implements PlugIn
gd
.
addStringField
(
"Hdf5 chunk sizes"
,
lastChunkSizes
,
25
);
final
TextField
tfChunkSizes
=
(
TextField
)
gd
.
getStringFields
().
lastElement
();
if
(
askForXMLPath
)
PluginHelper
.
addSaveAsFileField
(
gd
,
"Export path"
,
lastExportPath
,
25
);
final
String
autoSubsampling
=
ProposeMipmaps
.
getArrayString
(
autoMipmapSettings
.
getExportResolutions
()
);
...
...
@@ -226,10 +257,14 @@ public class ResavePlugin implements PlugIn
continue
;
}
final
File
seqFile
,
hdf5File
;
if
(
askForXMLPath
)
{
String
seqFilename
=
lastExportPath
;
if
(
!
seqFilename
.
endsWith
(
".xml"
)
)
seqFilename
+=
".xml"
;
final
File
seqFile
=
new
File
(
seqFilename
);
seqFile
=
new
File
(
seqFilename
);
final
File
parent
=
seqFile
.
getParentFile
();
if
(
parent
==
null
||
!
parent
.
exists
()
||
!
parent
.
isDirectory
()
)
{
...
...
@@ -237,7 +272,12 @@ public class ResavePlugin implements PlugIn
continue
;
}
final
String
hdf5Filename
=
seqFilename
.
substring
(
0
,
seqFilename
.
length
()
-
4
)
+
".h5"
;
final
File
hdf5File
=
new
File
(
hdf5Filename
);
hdf5File
=
new
File
(
hdf5Filename
);
}
else
{
seqFile
=
hdf5File
=
null
;
}
return
new
Parameters
(
lastSetMipmapManual
,
resolutions
,
subdivisions
,
seqFile
,
hdf5File
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment