Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
bb7918e0
Commit
bb7918e0
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Warning message shown for large files.
parent
4d45dc12
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/data/image.py
+19
-5
19 additions, 5 deletions
fsl/data/image.py
fsl/data/strings.py
+3
-1
3 additions, 1 deletion
fsl/data/strings.py
fsl/utils/dialog.py
+8
-0
8 additions, 0 deletions
fsl/utils/dialog.py
with
30 additions
and
6 deletions
fsl/data/image.py
+
19
−
5
View file @
bb7918e0
...
@@ -551,26 +551,28 @@ def loadImage(filename):
...
@@ -551,26 +551,28 @@ def loadImage(filename):
import
wx
import
wx
if
wx
.
GetApp
()
is
not
None
:
if
wx
.
GetApp
()
is
not
None
:
haveGui
=
True
haveGui
=
True
import
fsl.utils.dialog
as
fsldlg
except
:
except
:
pass
pass
realFilename
=
filename
realFilename
=
filename
mbytes
=
op
.
getsize
(
filename
)
/
1048576.0
mbytes
=
op
.
getsize
(
filename
)
/
1048576.0
# The mbytes limit is arbitrary
# The mbytes limit is arbitrary
if
filename
.
endswith
(
'
.
nii.
gz
'
)
and
mbytes
>
512
:
if
filename
.
endswith
(
'
.gz
'
)
and
mbytes
>
512
:
unzipped
,
filename
=
tempfile
.
mkstemp
(
suffix
=
'
.nii
'
)
unzipped
,
filename
=
tempfile
.
mkstemp
(
suffix
=
'
.nii
'
)
unzipped
=
os
.
fdopen
(
unzipped
)
unzipped
=
os
.
fdopen
(
unzipped
)
msg
=
strings
.
messages
[
'
image.loadImage.decompress
'
]
msg
=
strings
.
messages
[
'
image.loadImage.decompress
'
]
msg
=
msg
.
format
(
realFilename
,
mbytes
,
filename
)
msg
=
msg
.
format
(
op
.
basename
(
realFilename
)
,
mbytes
,
filename
)
if
not
haveGui
:
if
not
haveGui
:
log
.
info
(
msg
)
log
.
info
(
msg
)
else
:
else
:
busyDlg
=
wx
.
BusyInfo
(
msg
,
wx
.
GetTopLevelWindows
()[
0
])
busyDlg
=
fsldlg
.
SimpleMessageDialog
(
message
=
msg
)
busyDlg
.
Show
()
gzip
=
[
'
gzip
'
,
'
-d
'
,
'
-c
'
,
realFilename
]
gzip
=
[
'
gzip
'
,
'
-d
'
,
'
-c
'
,
realFilename
]
log
.
debug
(
'
Running {} > {}
'
.
format
(
'
'
.
join
(
gzip
),
filename
))
log
.
debug
(
'
Running {} > {}
'
.
format
(
'
'
.
join
(
gzip
),
filename
))
...
@@ -594,7 +596,19 @@ def loadImage(filename):
...
@@ -594,7 +596,19 @@ def loadImage(filename):
log
.
debug
(
'
Loading image from {}
'
.
format
(
filename
))
log
.
debug
(
'
Loading image from {}
'
.
format
(
filename
))
import
nibabel
as
nib
import
nibabel
as
nib
return
nib
.
load
(
filename
),
filename
if
haveGui
and
(
mbytes
>
512
):
msg
=
strings
.
messages
[
'
image.loadImage.largeFile
'
]
msg
=
msg
.
format
(
op
.
basename
(
filename
),
mbytes
)
busyDlg
=
fsldlg
.
SimpleMessageDialog
(
message
=
msg
)
busyDlg
.
Show
()
image
=
nib
.
load
(
filename
)
if
haveGui
and
(
mbytes
>
512
):
busyDlg
.
Destroy
()
return
image
,
filename
def
saveImage
(
image
,
fromDir
=
None
):
def
saveImage
(
image
,
fromDir
=
None
):
...
...
This diff is collapsed.
Click to expand it.
fsl/data/strings.py
+
3
−
1
View file @
bb7918e0
...
@@ -47,9 +47,11 @@ messages = TypeDict({
...
@@ -47,9 +47,11 @@ messages = TypeDict({
'
image.saveImage.error
'
:
'
An error occurred saving the file.
'
'
image.saveImage.error
'
:
'
An error occurred saving the file.
'
'
Details: {}
'
,
'
Details: {}
'
,
'
image.loadImage.decompress
'
:
'
{} is a large file ({} MB) -
'
'
image.loadImage.decompress
'
:
'
{} is a large file ({
:0.0f
} MB) -
'
'
decompressing to {}, to allow memory
'
'
decompressing to {}, to allow memory
'
'
mapping...
'
,
'
mapping...
'
,
'
image.loadImage.largeFile
'
:
'
{} is a large file ({:0.0f}) MB) -
'
'
loading it may take some time...
'
,
'
ProcessingDialog.error
'
:
'
An error has occurred: {}
'
'
ProcessingDialog.error
'
:
'
An error has occurred: {}
'
'
\n\n
Details: {}
'
,
'
\n\n
Details: {}
'
,
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/dialog.py
+
8
−
0
View file @
bb7918e0
...
@@ -103,6 +103,14 @@ class SimpleMessageDialog(wx.Dialog):
...
@@ -103,6 +103,14 @@ class SimpleMessageDialog(wx.Dialog):
self
.
SetMessage
(
message
)
self
.
SetMessage
(
message
)
def
Show
(
self
):
"""
Overrides ``wx.Dialog.Show``. Calls that method, and calls
``wx.Yield``.
"""
wx
.
Dialog
.
Show
(
self
)
wx
.
Yield
()
def
SetMessage
(
self
,
msg
):
def
SetMessage
(
self
,
msg
):
"""
Updates the message shown on this ``SimpleMessageDialog``.
"""
Updates the message shown on this ``SimpleMessageDialog``.
...
...
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